diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2360a13..2d93316 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -3,11 +3,11 @@ on: pull_request: branches: - master - - release-1.4 + - release-* push: branches: - master - - release-1.4 + - release-* tags: '*' jobs: test: @@ -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: @@ -31,22 +32,15 @@ jobs: exclude: - os: macOS-latest arch: x86 + - os: windows-latest + version: '1.3' # `curl_easy_setopt: 48` error on github CI 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 diff --git a/src/Curl/Curl.jl b/src/Curl/Curl.jl index fa76379..3fc9310 100644 --- a/src/Curl/Curl.jl +++ b/src/Curl/Curl.jl @@ -26,6 +26,7 @@ export add_handle, remove_handle +using Base: @lock using LibCURL using LibCURL: curl_off_t, libcurl # not exported: https://github.com/JuliaWeb/LibCURL.jl/issues/87 diff --git a/src/Curl/Multi.jl b/src/Curl/Multi.jl index b017f88..c6ed079 100644 --- a/src/Curl/Multi.jl +++ b/src/Curl/Multi.jl @@ -8,6 +8,7 @@ mutable struct Multi function Multi(grace::Integer = typemax(UInt64)) multi = new(ReentrantLock(), C_NULL, nothing, Easy[], grace) finalizer(done!, multi) + @lock MULTIS_LOCK push!(filter!(m -> m.value isa Multi, MULTIS), WeakRef(multi)) return multi end end @@ -52,6 +53,18 @@ function add_handle(multi::Multi, easy::Easy) 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 = @lock MULTIS_LOCK (isempty(MULTIS) ? nothing : pop!(MULTIS)) + w === nothing && break + w = w.value + w isa Multi && done!(w) + end +end + function remove_handle(multi::Multi, easy::Easy) lock(multi.lock) do @check curl_multi_remove_handle(multi.handle, easy.handle) diff --git a/src/Downloads.jl b/src/Downloads.jl index 6a91312..8d3cace 100644 --- a/src/Downloads.jl +++ b/src/Downloads.jl @@ -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