]> granicus.if.org Git - curl/commitdiff
curl_multi_wait: no wait if no descriptors to wait for
authorDaniel Stenberg <daniel@haxx.se>
Tue, 9 Oct 2012 20:19:49 +0000 (22:19 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Tue, 9 Oct 2012 20:19:49 +0000 (22:19 +0200)
This is a minor change in behavior after having been pointed out by Mark
Tully and discussed on the list. Initially this case would internally
call poll() with no sockets and a timeout which would equal a sleep for
that specified time.

Bug: http://curl.haxx.se/mail/lib-2012-10/0076.html
Reported by: Mark Tully

docs/libcurl/curl_multi_wait.3
lib/multi.c

index ad97d47c520acda6ef8c301c932b11bc939ec1ca..b14760bf3f5c61445dd79fb6cf30b33db0d2f84f 100644 (file)
@@ -43,6 +43,9 @@ similar to \fIpoll(2)\fP's pollfd structure to be waited on in the same call.
 On completion, if \fInumfds\fP is supplied, it will be populated with the
 number of file descriptors on which interesting events occured.
 
+If no extra file descriptors are provided and libcurl has no file descriptor
+to offer to wait for, this function will return immediately.
+
 This function is encouraged to be used instead of select(3) when using the
 multi interface to allow applications to easier circumvent the common problem
 with 1024 maximum file descriptors.
@@ -67,6 +70,6 @@ events such as the socket being clear to write without blocking.
 CURLMcode type, general libcurl multi interface error code. See
 \fIlibcurl-errors(3)\fP
 .SH AVAILABILITY
-This function was added in libcurl 7.28.0
+This function was added in libcurl 7.28.0.
 .SH "SEE ALSO"
 .BR curl_multi_fdset "(3), " curl_multi_perform "(3)"
index 6506b5ee48a8a85865864c3316b1da0c63a78396..938846769dc3b68544e36055090e3c811c9a4bb6 100644 (file)
@@ -1024,8 +1024,12 @@ CURLMcode curl_multi_wait(CURLM *multi_handle,
     ++nfds;
   }
 
-  /* wait... */
-  i = Curl_poll(ufds, nfds, timeout_ms);
+  if(nfds)
+    /* wait... */
+    i = Curl_poll(ufds, nfds, timeout_ms);
+  else
+    i = 0;
+
   free(ufds);
   if(ret)
     *ret = i;