Skip to content

Commit a9d274f

Browse files
Close Multi timers atexit. Add 1.6 CI (#234)
1 parent 8a614d5 commit a9d274f

File tree

4 files changed

+22
-17
lines changed

4 files changed

+22
-17
lines changed

.github/workflows/ci.yml

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ on:
33
pull_request:
44
branches:
55
- master
6-
- release-1.4
6+
- release-*
77
push:
88
branches:
99
- master
10-
- release-1.4
10+
- release-*
1111
tags: '*'
1212
jobs:
1313
test:
@@ -18,6 +18,7 @@ jobs:
1818
matrix:
1919
version:
2020
- '1.3'
21+
- '1.6'
2122
- '1' # automatically expands to the latest stable 1.x release of Julia.
2223
- 'nightly'
2324
os:
@@ -31,22 +32,15 @@ jobs:
3132
exclude:
3233
- os: macOS-latest
3334
arch: x86
35+
- os: windows-latest
36+
version: '1.3' # `curl_easy_setopt: 48` error on github CI
3437
steps:
35-
- uses: actions/checkout@v2
38+
- uses: actions/checkout@v4
3639
- uses: julia-actions/setup-julia@v1
3740
with:
3841
version: ${{ matrix.version }}
3942
arch: ${{ matrix.arch }}
40-
- uses: actions/cache@v1
41-
env:
42-
cache-name: cache-artifacts
43-
with:
44-
path: ~/.julia/artifacts
45-
key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ hashFiles('**/Project.toml') }}
46-
restore-keys: |
47-
${{ runner.os }}-test-${{ env.cache-name }}-
48-
${{ runner.os }}-test-${{ matrix.os }}
49-
${{ runner.os }}-
43+
- uses: julia-actions/cache@v1
5044
- run: julia --color=yes .ci/test_and_change_uuid.jl
5145
- uses: julia-actions/julia-buildpkg@v1
5246
- uses: julia-actions/julia-runtest@v1

src/Curl/Curl.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export
2626
add_handle,
2727
remove_handle
2828

29+
using Base: @lock
2930
using LibCURL
3031
using LibCURL: curl_off_t, libcurl
3132
# not exported: https://github.com/JuliaWeb/LibCURL.jl/issues/87

src/Curl/Multi.jl

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ mutable struct Multi
88
function Multi(grace::Integer = typemax(UInt64))
99
multi = new(ReentrantLock(), C_NULL, nothing, Easy[], grace)
1010
finalizer(done!, multi)
11+
@lock MULTIS_LOCK push!(filter!(m -> m.value isa Multi, MULTIS), WeakRef(multi))
1112
return multi
1213
end
1314
end
@@ -52,6 +53,18 @@ function add_handle(multi::Multi, easy::Easy)
5253
end
5354
end
5455

56+
const MULTIS_LOCK = Base.ReentrantLock()
57+
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
67+
5568
function remove_handle(multi::Multi, easy::Easy)
5669
lock(multi.lock) do
5770
@check curl_multi_remove_handle(multi.handle, easy.handle)

src/Downloads.jl

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -467,11 +467,8 @@ end
467467

468468
# Precompile
469469
let
470-
d = Downloader(; grace=0.01)
470+
d = Downloader()
471471
download("file://" * @__FILE__; downloader=d)
472-
# Ref https://github.com/JuliaLang/julia/issues/49513
473-
# we wait for the grace task to finish
474-
sleep(0.05)
475472
precompile(Tuple{typeof(Downloads.download), String, String})
476473
precompile(Tuple{typeof(Downloads.Curl.status_2xx_ok), Int64})
477474
end

0 commit comments

Comments
 (0)