Skip to content

Commit 51e5321

Browse files
authored
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
1 parent 05f9ec2 commit 51e5321

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/Downloads.jl

+2-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ function grace_ms(grace::Real)
5151
end
5252

5353
function easy_hook(downloader::Downloader, easy::Easy, info::NamedTuple)
54-
downloader.easy_hook !== nothing && downloader.easy_hook(easy, info)
54+
hook = downloader.easy_hook
55+
hook !== nothing && Base.invokelatest(hook, easy, info)
5556
end
5657

5758
get_ca_roots() = Curl.SYSTEM_SSL ? ca_roots() : ca_roots_path()

0 commit comments

Comments
 (0)