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:
Dennis Felsing 2024-02-16 18:07:02 +00:00 committed by GitHub
commit 1bc11c517d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

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