forked from lix-project/lix
download: if there are active requests, never sleep for 10s
In some versions/configurations libcurl doesn't handle timeouts (especially DNS timeouts) in a way that wakes curl_multi_wait. This doesn't appear to be a problem if using c-ares, FWIW.
This commit is contained in:
parent
74144ae845
commit
6bf7dc1baf
|
@ -503,10 +503,11 @@ struct CurlDownloader : public Downloader
|
||||||
extraFDs[0].fd = wakeupPipe.readSide.get();
|
extraFDs[0].fd = wakeupPipe.readSide.get();
|
||||||
extraFDs[0].events = CURL_WAIT_POLLIN;
|
extraFDs[0].events = CURL_WAIT_POLLIN;
|
||||||
extraFDs[0].revents = 0;
|
extraFDs[0].revents = 0;
|
||||||
|
long maxSleepTimeMs = items.empty() ? 10000 : 100;
|
||||||
auto sleepTimeMs =
|
auto sleepTimeMs =
|
||||||
nextWakeup != std::chrono::steady_clock::time_point()
|
nextWakeup != std::chrono::steady_clock::time_point()
|
||||||
? std::max(0, (int) std::chrono::duration_cast<std::chrono::milliseconds>(nextWakeup - std::chrono::steady_clock::now()).count())
|
? std::max(0, (int) std::chrono::duration_cast<std::chrono::milliseconds>(nextWakeup - std::chrono::steady_clock::now()).count())
|
||||||
: 10000;
|
: maxSleepTimeMs;
|
||||||
vomit("download thread waiting for %d ms", sleepTimeMs);
|
vomit("download thread waiting for %d ms", sleepTimeMs);
|
||||||
mc = curl_multi_wait(curlm, extraFDs, 1, sleepTimeMs, &numfds);
|
mc = curl_multi_wait(curlm, extraFDs, 1, sleepTimeMs, &numfds);
|
||||||
if (mc != CURLM_OK)
|
if (mc != CURLM_OK)
|
||||||
|
|
Loading…
Reference in a new issue