mirror of
https://github.com/luanti-org/luanti.git
synced 2025-09-15 18:57:08 +00:00
Do not block in httpfetch_request_clear() (#16303)
This commit is contained in:
parent
80be9bf76e
commit
83a7e22cf7
1 changed files with 15 additions and 7 deletions
|
@ -402,6 +402,8 @@ const HTTPFetchResult * HTTPFetchOngoing::complete(CURLcode res)
|
|||
HTTPFetchOngoing::~HTTPFetchOngoing()
|
||||
{
|
||||
if (multi) {
|
||||
// Note: this can block if curl is stuck waiting for DNS, see
|
||||
// <https://github.com/luanti-org/luanti/issues/16272>
|
||||
CURLMcode mres = curl_multi_remove_handle(multi, curl);
|
||||
if (mres != CURLM_OK) {
|
||||
errorstream << "curl_multi_remove_handle"
|
||||
|
@ -635,6 +637,8 @@ protected:
|
|||
while (!stopRequested()) {
|
||||
BEGIN_DEBUG_EXCEPTION_HANDLER
|
||||
|
||||
const u64 t0 = porting::getTimeMs();
|
||||
|
||||
/*
|
||||
Handle new async requests
|
||||
*/
|
||||
|
@ -667,6 +671,16 @@ protected:
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
If we took suspiciously long, warn.
|
||||
*/
|
||||
const u64 tdelta = porting::getTimeMs() - t0;
|
||||
if (tdelta > 300) {
|
||||
warningstream << "CurlFetchThread blocked for " << tdelta << "ms"
|
||||
<< std::endl;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
If there are ongoing requests, wait for data
|
||||
(with a timeout of 100ms so that new requests
|
||||
|
@ -738,13 +752,7 @@ void httpfetch_async(const HTTPFetchRequest &fetch_request)
|
|||
|
||||
static void httpfetch_request_clear(u64 caller)
|
||||
{
|
||||
if (g_httpfetch_thread->isRunning()) {
|
||||
Event event;
|
||||
g_httpfetch_thread->requestClear(caller, &event);
|
||||
event.wait();
|
||||
} else {
|
||||
g_httpfetch_thread->requestClear(caller, nullptr);
|
||||
}
|
||||
g_httpfetch_thread->requestClear(caller, nullptr);
|
||||
}
|
||||
|
||||
bool httpfetch_sync_interruptible(const HTTPFetchRequest &fetch_request,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue