Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/Curl/Multi.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ mutable struct Multi
end

function init!(multi::Multi)
uv_timer_stop(multi.timer)
multi.handle != C_NULL && return
multi.handle = curl_multi_init()
add_callbacks(multi)
set_defaults(multi)
Expand All @@ -42,9 +42,12 @@ end

function add_handle(multi::Multi, easy::Easy)
lock(multi.lock) do
isempty(multi.easies) && preserve_handle(multi)
multi.handle == C_NULL && init!(multi)
if isempty(multi.easies)
preserve_handle(multi)
uv_timer_stop(multi.timer) # stop grace timer
end
push!(multi.easies, easy)
init!(multi)
@check curl_multi_add_handle(multi.handle, easy.handle)
end
end
Expand Down
6 changes: 6 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,12 @@ include("setup.jl")
head = String(read!(open(file), Vector{UInt8}(undef, 16)))
@test head == "\x1f\x8b\b\0\xa5T.\\\x02\x03\xec]{s۶"
end

@testset "grace cleanup" begin
dl = Downloader(grace=1)
Downloads.download("https://httpbingo.org/drip"; downloader=dl)
Downloads.download("https://httpbingo.org/drip"; downloader=dl)
end
end

Downloads.DOWNLOADER[] = nothing
Expand Down