Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Close Multi timers atexit. Add 1.6 CI #234

Merged
merged 15 commits into from
Jan 13, 2024
15 changes: 15 additions & 0 deletions src/Curl/Multi.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@
function Multi(grace::Integer = typemax(UInt64))
multi = new(ReentrantLock(), C_NULL, nothing, Easy[], grace)
finalizer(done!, multi)
lock(MULTIS_LOCK)
try
push!(MULTIS, WeakRef(multi))
catch
unlock(MULTIS_LOCK)

Check warning on line 15 in src/Curl/Multi.jl

View check run for this annotation

Codecov / codecov/patch

src/Curl/Multi.jl#L15

Added line #L15 was not covered by tests
end
IanButterworth marked this conversation as resolved.
Show resolved Hide resolved
return multi
end
end
Expand Down Expand Up @@ -52,6 +58,15 @@
end
end

const MULTIS_LOCK = Base.ReentrantLock()
const MULTIS = WeakRef[]
# Close any Multis and their timers at exit that haven't been finalized by then
Base.atexit() do
for w in MULTIS
w.value isa Multi && done!(w.value)
end

Check warning on line 67 in src/Curl/Multi.jl

View check run for this annotation

Codecov / codecov/patch

src/Curl/Multi.jl#L65-L67

Added lines #L65 - L67 were not covered by tests
IanButterworth marked this conversation as resolved.
Show resolved Hide resolved
end

function remove_handle(multi::Multi, easy::Easy)
lock(multi.lock) do
@check curl_multi_remove_handle(multi.handle, easy.handle)
Expand Down
5 changes: 1 addition & 4 deletions src/Downloads.jl
Original file line number Diff line number Diff line change
Expand Up @@ -467,11 +467,8 @@ end

# Precompile
let
d = Downloader(; grace=0.01)
d = Downloader()
download("file://" * @__FILE__; downloader=d)
# Ref https://github.com/JuliaLang/julia/issues/49513
# we wait for the grace task to finish
sleep(0.05)
precompile(Tuple{typeof(Downloads.download), String, String})
precompile(Tuple{typeof(Downloads.Curl.status_2xx_ok), Int64})
end
Expand Down
Loading