Skip to content

Commit

Permalink
Merge pull request #6 from bluesmoon/remove_handle
Browse files Browse the repository at this point in the history
Add tests and fix bugs in curl_multi_remove_handle method definition.
  • Loading branch information
bluesmoon authored Oct 11, 2023
2 parents e42b56f + 0b4e87c commit 1443a49
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/CurlHTTP.jl
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ function LibCURL.curl_multi_perform(curl::CurlMulti)
numfds = Ref{Cint}()

while still_running[] > 0
mc = curl_multi_perform(curl.handle, still_running)
mc = curl_multi_perform(curl, still_running)

if mc == CURLM_OK
mc = curl_multi_wait(curl.handle, C_NULL, 0, 1000, numfds)
Expand Down Expand Up @@ -434,16 +434,16 @@ function LibCURL.curl_multi_remove_handle(multi::CurlMulti, easy::CurlEasy)
filter!(pool_entry -> pool_entry.uuid != easy.uuid, multi.pool)
curl_multi_remove_handle(multi.handle, easy.handle)
end
function LibCURL.curl_multi_remove_handle(multi::CurlMulti, easy_uuid::AbstractString)
LibCURL.curl_multi_remove_handle(multi::CurlMulti, easy_uuid::AbstractString) = curl_multi_remove_handle(multi, Base.UUID(easy_uuid))
function LibCURL.curl_multi_remove_handle(multi::CurlMulti, easy_uuid::Base.UUID)
easy = findfirst(pool_entry -> pool_entry.uuid == easy_uuid, multi.pool)
if isnothing(easy)
return nothing
end

easy = multi.pool[easy]

filter!(pool_entry -> pool_entry.uuid != easy_uuid, multi.pool)
curl_multi_remove_handle(multi.handle, easy.handle)
curl_multi_remove_handle(multi, easy)
end


Expand Down
6 changes: 5 additions & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,8 @@ function test_multi_writeCB()
@test CURLM_OK == res
@test 3 == length(responses)

@testset "Response $(r[:i])" for r in responses
@testset "Response $(p.userdata[:i])" for p in curl.pool
r = p.userdata
@test haskey(r, :http_status)
@test r[:http_status] == 200

Expand All @@ -309,7 +310,10 @@ function test_multi_writeCB()

@test haskey(r, :errormessage)
@test "" == r[:errormessage]

@test CURLM_OK == curl_multi_remove_handle(curl, p.uuid)
end
@test nothing == curl_multi_remove_handle(curl, CurlHTTP.UUIDs.uuid4())
end

function test_Certs()
Expand Down

0 comments on commit 1443a49

Please sign in to comment.