From 51e53218dfebdc51daab99fe12b18f3fcece7854 Mon Sep 17 00:00:00 2001 From: Tanmay Mohapatra Date: Wed, 5 Jun 2024 20:32:47 +0530 Subject: [PATCH] fix: use invokelatest for easy_hook, avoid race (#241) - 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()