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
18 changes: 5 additions & 13 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ on:
pull_request:
branches:
- master
- release-1.4
- release-*
push:
branches:
- master
- release-1.4
- release-*
tags: '*'
jobs:
test:
Expand All @@ -18,6 +18,7 @@ jobs:
matrix:
version:
- '1.3'
- '1.6'
- '1' # automatically expands to the latest stable 1.x release of Julia.
- 'nightly'
os:
Expand All @@ -32,21 +33,12 @@ jobs:
- os: macOS-latest
arch: x86
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- uses: julia-actions/setup-julia@v1
with:
version: ${{ matrix.version }}
arch: ${{ matrix.arch }}
- uses: actions/cache@v1
env:
cache-name: cache-artifacts
with:
path: ~/.julia/artifacts
key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ hashFiles('**/Project.toml') }}
restore-keys: |
${{ runner.os }}-test-${{ env.cache-name }}-
${{ runner.os }}-test-${{ matrix.os }}
${{ runner.os }}-
- uses: julia-actions/cache@v1
- run: julia --color=yes .ci/test_and_change_uuid.jl
- uses: julia-actions/julia-buildpkg@v1
- uses: julia-actions/julia-runtest@v1
Expand Down
13 changes: 13 additions & 0 deletions src/Curl/Multi.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
function Multi(grace::Integer = typemax(UInt64))
multi = new(ReentrantLock(), C_NULL, nothing, Easy[], grace)
finalizer(done!, multi)
Base.@lock MULTIS_LOCK push!(filter!(m -> m.value isa Multi, MULTIS), WeakRef(multi))
IanButterworth marked this conversation as resolved.
Show resolved Hide resolved
return multi
end
end
Expand Down Expand Up @@ -52,6 +53,18 @@
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
while true
w = Base.@lock MULTIS_LOCK (isempty(MULTIS) ? nothing : pop!(MULTIS))
w === nothing && break
w = w.value
w isa Multi && done!(w)
end

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

View check run for this annotation

Codecov / codecov/patch

src/Curl/Multi.jl#L60-L65

Added lines #L60 - L65 were not covered by tests
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