From 5707f96da1bc33f3eada147a4925205f978d422e Mon Sep 17 00:00:00 2001 From: tan Date: Thu, 18 Apr 2024 10:49:22 +0530 Subject: [PATCH] fix: use invokelatest for easy_hook, avoid race - uses `Base.invokelatest` while invoking `easy_hook` methods because the downloads instance and callbacks may be in different world ages. - stores the `easy_hook` in local var to avoid races that cn happen between checking and invoking fixes #240 --- src/Downloads.jl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Downloads.jl b/src/Downloads.jl index 7a6cde4..5a3c214 100644 --- a/src/Downloads.jl +++ b/src/Downloads.jl @@ -51,7 +51,8 @@ function grace_ms(grace::Real) end function easy_hook(downloader::Downloader, easy::Easy, info::NamedTuple) - downloader.easy_hook !== nothing && downloader.easy_hook(easy, info) + hook = downloader.easy_hook + hook !== nothing && Base.invokelatest(hook, easy, info) end get_ca_roots() = Curl.SYSTEM_SSL ? ca_roots() : ca_roots_path()