mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-18 14:08:19 +00:00
Merge pull request #7981 from Robyt3/Http-Cancel-New-Jobs-On-Shutdown
Abort new HTTP requests immediately when shutting down `CHttp`
This commit is contained in:
commit
1bc11c517d
|
@ -560,9 +560,16 @@ void CHttp::RunLoop()
|
|||
|
||||
void CHttp::Run(std::shared_ptr<IHttpRequest> pRequest)
|
||||
{
|
||||
std::shared_ptr<CHttpRequest> pRequestImpl = std::static_pointer_cast<CHttpRequest>(pRequest);
|
||||
std::unique_lock Lock(m_Lock);
|
||||
if(m_Shutdown)
|
||||
{
|
||||
str_copy(pRequestImpl->m_aErr, "Shutting down");
|
||||
pRequestImpl->OnCompletionInternal(CURLE_ABORTED_BY_CALLBACK);
|
||||
return;
|
||||
}
|
||||
m_Cv.wait(Lock, [this]() { return m_State != CHttp::UNINITIALIZED; });
|
||||
m_PendingRequests.emplace_back(std::static_pointer_cast<CHttpRequest>(pRequest));
|
||||
m_PendingRequests.emplace_back(pRequestImpl);
|
||||
curl_multi_wakeup(m_pMultiH);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue