diff --git a/src/lib/curl/Global.cxx b/src/lib/curl/Global.cxx index 4118d50ce..3111417e8 100644 --- a/src/lib/curl/Global.cxx +++ b/src/lib/curl/Global.cxx @@ -155,14 +155,11 @@ CurlSocket::OnSocketReady(unsigned flags) noexcept } void -CurlGlobal::Add(CURL *easy, CurlRequest &request) +CurlGlobal::Add(CurlRequest &r) { assert(GetEventLoop().IsInside()); - assert(easy != nullptr); - curl_easy_setopt(easy, CURLOPT_PRIVATE, &request); - - CURLMcode mcode = curl_multi_add_handle(multi.Get(), easy); + CURLMcode mcode = curl_multi_add_handle(multi.Get(), r.Get()); if (mcode != CURLM_OK) throw FormatRuntimeError("curl_multi_add_handle() failed: %s", curl_multi_strerror(mcode)); @@ -171,13 +168,11 @@ CurlGlobal::Add(CURL *easy, CurlRequest &request) } void -CurlGlobal::Remove(CURL *easy) noexcept +CurlGlobal::Remove(CurlRequest &r) noexcept { assert(GetEventLoop().IsInside()); - assert(easy != nullptr); - - curl_multi_remove_handle(multi.Get(), easy); + curl_multi_remove_handle(multi.Get(), r.Get()); InvalidateSockets(); } diff --git a/src/lib/curl/Global.hxx b/src/lib/curl/Global.hxx index ede652cfe..0dc791893 100644 --- a/src/lib/curl/Global.hxx +++ b/src/lib/curl/Global.hxx @@ -54,8 +54,8 @@ public: return timeout_event.GetEventLoop(); } - void Add(CURL *easy, CurlRequest &request); - void Remove(CURL *easy) noexcept; + void Add(CurlRequest &r); + void Remove(CurlRequest &r) noexcept; void Assign(curl_socket_t fd, CurlSocket &cs) noexcept { curl_multi_assign(multi.Get(), fd, &cs); diff --git a/src/lib/curl/Request.cxx b/src/lib/curl/Request.cxx index 809ef6ce4..8e576cd24 100644 --- a/src/lib/curl/Request.cxx +++ b/src/lib/curl/Request.cxx @@ -75,7 +75,7 @@ CurlRequest::Start() { assert(!registered); - global.Add(easy.Get(), *this); + global.Add(*this); registered = true; } @@ -93,7 +93,7 @@ CurlRequest::Stop() noexcept if (!registered) return; - global.Remove(easy.Get()); + global.Remove(*this); registered = false; }