aboutsummaryrefslogtreecommitdiff
path: root/lib/multi.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/multi.c')
-rw-r--r--lib/multi.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/lib/multi.c b/lib/multi.c
index f17b33377..97efc7066 100644
--- a/lib/multi.c
+++ b/lib/multi.c
@@ -1541,6 +1541,7 @@ CURLMcode curl_multi_perform(CURLM *multi_handle, int *running_handles)
if( CURLM_OK >= returncode )
update_timer(multi);
+
return returncode;
}
@@ -1951,9 +1952,19 @@ static CURLMcode multi_timeout(struct Curl_multi *multi,
/* splay the lowest to the bottom */
multi->timetree = Curl_splay(tv_zero, multi->timetree);
- if(Curl_splaycomparekeys(multi->timetree->key, now) > 0)
+ if(Curl_splaycomparekeys(multi->timetree->key, now) > 0) {
/* some time left before expiration */
*timeout_ms = curlx_tvdiff(multi->timetree->key, now);
+ if(!*timeout_ms)
+ /*
+ * Since we only provide millisecond resolution on the returned value
+ * and the diff might be less than one millisecond here, we don't
+ * return zero as that may cause short bursts of busyloops on fast
+ * processors while the diff is still present but less than one
+ * millisecond! instead we return 1 until the time is ripe.
+ */
+ *timeout_ms=1;
+ }
else
/* 0 means immediately */
*timeout_ms = 0;