Skip to content

Commit 1061ecc

Browse files
Fix setting atexit. Fixes trailing download tasks during precompilation (#257)
1 parent b871386 commit 1061ecc

File tree

3 files changed

+15
-13
lines changed

3 files changed

+15
-13
lines changed

src/Curl/Curl.jl

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,6 @@ using Base: OS_HANDLE, preserve_handle, unpreserve_handle
6565

6666
include("utils.jl")
6767

68-
function __init__()
69-
@check curl_global_init(CURL_GLOBAL_ALL)
70-
end
71-
7268
const CURL_VERSION_INFO = unsafe_load(curl_version_info(CURLVERSION_NOW))
7369
if CURL_VERSION_INFO.ssl_version == Base.C_NULL
7470
const SSL_VERSION = ""
@@ -91,6 +87,20 @@ end
9187
include("Easy.jl")
9288
include("Multi.jl")
9389

90+
function __init__()
91+
@check curl_global_init(CURL_GLOBAL_ALL)
92+
93+
# Close any Multis and their timers at exit that haven't been finalized by then
94+
Base.atexit() do
95+
while true
96+
w = @lock MULTIS_LOCK (isempty(MULTIS) ? nothing : pop!(MULTIS))
97+
w === nothing && break
98+
w = w.value
99+
w isa Multi && done!(w)
100+
end
101+
end
102+
end
103+
94104
function with_handle(f, handle::Union{Multi, Easy})
95105
try f(handle)
96106
finally

src/Curl/Multi.jl

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,6 @@ end
5555

5656
const MULTIS_LOCK = Base.ReentrantLock()
5757
const MULTIS = WeakRef[]
58-
# Close any Multis and their timers at exit that haven't been finalized by then
59-
Base.atexit() do
60-
while true
61-
w = @lock MULTIS_LOCK (isempty(MULTIS) ? nothing : pop!(MULTIS))
62-
w === nothing && break
63-
w = w.value
64-
w isa Multi && done!(w)
65-
end
66-
end
6758

6859
function remove_handle(multi::Multi, easy::Easy)
6960
lock(multi.lock) do

src/Downloads.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,7 @@ end
468468

469469
# Precompile
470470
let
471+
Curl.__init__()
471472
d = Downloader()
472473
f = mktemp()[1]
473474
download("file://" * f; downloader=d)

0 commit comments

Comments
 (0)