mirror of
https://github.com/curl/curl.git
synced 2026-06-01 22:14:17 +03:00
multi: fix multi_wait() timeout handling
- determine the actual poll timeout *after* all sockets have been collected. Protocols and connection filters may install new timeouts during collection. - add debug logging to test1533 where the mistake was noticed Reported-by: Matt Jolly Fixes #13782 Closes #13825
This commit is contained in:
parent
3b9569c3e2
commit
c8096668ae
3 changed files with 16 additions and 8 deletions
15
lib/multi.c
15
lib/multi.c
|
|
@ -1366,13 +1366,6 @@ static CURLMcode multi_wait(struct Curl_multi *multi,
|
|||
if(timeout_ms < 0)
|
||||
return CURLM_BAD_FUNCTION_ARGUMENT;
|
||||
|
||||
/* If the internally desired timeout is actually shorter than requested from
|
||||
the outside, then use the shorter time! But only if the internal timer
|
||||
is actually larger than -1! */
|
||||
(void)multi_timeout(multi, &timeout_internal);
|
||||
if((timeout_internal >= 0) && (timeout_internal < (long)timeout_ms))
|
||||
timeout_ms = (int)timeout_internal;
|
||||
|
||||
memset(ufds, 0, ufds_len * sizeof(struct pollfd));
|
||||
memset(&ps, 0, sizeof(ps));
|
||||
|
||||
|
|
@ -1476,6 +1469,14 @@ static CURLMcode multi_wait(struct Curl_multi *multi,
|
|||
#endif
|
||||
#endif
|
||||
|
||||
/* We check the internal timeout *AFTER* we collected all sockets to
|
||||
* poll. Collecting the sockets may install new timers by protocols
|
||||
* and connection filters.
|
||||
* Use the shorter one of the internal and the caller requested timeout. */
|
||||
(void)multi_timeout(multi, &timeout_internal);
|
||||
if((timeout_internal >= 0) && (timeout_internal < (long)timeout_ms))
|
||||
timeout_ms = (int)timeout_internal;
|
||||
|
||||
#if defined(ENABLE_WAKEUP) && defined(USE_WINSOCK)
|
||||
if(nfds || use_wakeup) {
|
||||
#else
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue