lib/curl/Request: require the caller to explicitly register the request
This allows constructing an instance in any thread, and register it inside the IOThread later.
This commit is contained in:
@@ -62,8 +62,6 @@ CurlRequest::CurlRequest(CurlGlobal &_global, const char *url,
|
||||
easy.SetOption(CURLOPT_NOSIGNAL, 1l);
|
||||
easy.SetOption(CURLOPT_CONNECTTIMEOUT, 10l);
|
||||
easy.SetOption(CURLOPT_URL, url);
|
||||
|
||||
global.Add(easy.Get(), *this);
|
||||
}
|
||||
|
||||
CurlRequest::~CurlRequest()
|
||||
@@ -71,19 +69,40 @@ CurlRequest::~CurlRequest()
|
||||
FreeEasy();
|
||||
}
|
||||
|
||||
void
|
||||
CurlRequest::Start()
|
||||
{
|
||||
assert(!registered);
|
||||
|
||||
global.Add(easy.Get(), *this);
|
||||
registered = true;
|
||||
}
|
||||
|
||||
void
|
||||
CurlRequest::Stop()
|
||||
{
|
||||
assert(registered);
|
||||
|
||||
global.Remove(easy.Get());
|
||||
registered = false;
|
||||
}
|
||||
|
||||
void
|
||||
CurlRequest::FreeEasy()
|
||||
{
|
||||
if (!easy)
|
||||
return;
|
||||
|
||||
global.Remove(easy.Get());
|
||||
if (registered)
|
||||
Stop();
|
||||
easy = nullptr;
|
||||
}
|
||||
|
||||
void
|
||||
CurlRequest::Resume()
|
||||
{
|
||||
assert(registered);
|
||||
|
||||
curl_easy_pause(easy.Get(), CURLPAUSE_CONT);
|
||||
|
||||
if (IsCurlOlderThan(0x072000))
|
||||
|
Reference in New Issue
Block a user