lib/curl/Global: remove CURL* parameter from Add() and Remove()

This commit is contained in:
Max Kellermann 2019-08-19 21:53:19 +02:00
parent 0c8ff56a15
commit 2934fc2507
3 changed files with 8 additions and 13 deletions

View File

@ -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();
}

View File

@ -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);

View File

@ -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;
}