From 2eb04914173ce41f778a5b9980f7bc9c04a96511 Mon Sep 17 00:00:00 2001 From: Stefan Karpinski <stefan@karpinski.org> Date: Thu, 21 Oct 2021 16:25:01 -0400 Subject: [PATCH] fix wrong definition of curl_socket_t on Windows --- src/Curl/Curl.jl | 24 +++++++++++++++++++++++- src/Curl/utils.jl | 6 ------ 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/src/Curl/Curl.jl b/src/Curl/Curl.jl index 3858689..fcfea37 100644 --- a/src/Curl/Curl.jl +++ b/src/Curl/Curl.jl @@ -26,13 +26,35 @@ export remove_handle using LibCURL -using LibCURL: curl_off_t +using LibCURL: curl_off_t, libcurl # not exported: https://github.com/JuliaWeb/LibCURL.jl/issues/87 # constants that LibCURL should have but doesn't const CURLE_PEER_FAILED_VERIFICATION = 60 const CURLSSLOPT_REVOKE_BEST_EFFORT = 1 << 3 +# these are incorrectly defined on Windows by LibCURL: +if Sys.iswindows() + const curl_socket_t = Base.OS_HANDLE + const CURL_SOCKET_TIMEOUT = Base.INVALID_OS_HANDLE +else + const curl_socket_t = Cint + const CURL_SOCKET_TIMEOUT = -1 +end + +# definitions affected by incorrect curl_socket_t (copied verbatim): +function curl_multi_socket_action(multi_handle, s, ev_bitmask, running_handles) + ccall((:curl_multi_socket_action, libcurl), CURLMcode, (Ptr{CURLM}, curl_socket_t, Cint, Ptr{Cint}), multi_handle, s, ev_bitmask, running_handles) +end +function curl_multi_assign(multi_handle, sockfd, sockp) + ccall((:curl_multi_assign, libcurl), CURLMcode, (Ptr{CURLM}, curl_socket_t, Ptr{Cvoid}), multi_handle, sockfd, sockp) +end + +# additional curl_multi_socket_action method +function curl_multi_socket_action(multi_handle, s, ev_bitmask) + curl_multi_socket_action(multi_handle, s, ev_bitmask, Ref{Cint}()) +end + using FileWatching using NetworkOptions using Base: OS_HANDLE, preserve_handle, unpreserve_handle diff --git a/src/Curl/utils.jl b/src/Curl/utils.jl index d77c4ab..e7aa08a 100644 --- a/src/Curl/utils.jl +++ b/src/Curl/utils.jl @@ -31,12 +31,6 @@ macro check(ex::Expr) end end -# additional libcurl methods - -function curl_multi_socket_action(multi_handle, s, ev_bitmask) - LibCURL.curl_multi_socket_action(multi_handle, s, ev_bitmask, Ref{Cint}()) -end - # curl string list structure struct curl_slist_t