Skip to content

Commit

Permalink
fix: use invokelatest for easy_hook, avoid race (#241)
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
tanmaykm authored Jun 5, 2024
1 parent 05f9ec2 commit 51e5321
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/Downloads.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 51e5321

Please sign in to comment.