]> granicus.if.org Git - curl/commitdiff
curl_multi_wait: Add parameter to return number of active sockets
authorSara Golemon <sgolemon@fb.com>
Sat, 15 Sep 2012 17:38:52 +0000 (10:38 -0700)
committerDaniel Stenberg <daniel@haxx.se>
Sun, 16 Sep 2012 17:58:02 +0000 (19:58 +0200)
Minor change to recently introduced function.  BC breaking, but since
curl_multi_wait() doesn't exist in any releases that should be fine.

docs/libcurl/curl_multi_wait.3
include/curl/multi.h
lib/multi.c
tests/libtest/lib1500.c

index 96b3c7e6665431f7ec01972748e153c4d69c4318..9250a77ebdad0d96a3570c30729f539e71dca441 100644 (file)
@@ -29,7 +29,8 @@ curl_multi_select - polls on all easy handles in a multi handle
 CURLMcode curl_multi_wait(CURLM *multi_handle,
                           struct curl_waitfd extra_fds[],
                           unsigned int extra_nfds,
-                          int timeout_ms);
+                          int timeout_ms,
+                          int *ret);
 .ad
 .SH DESCRIPTION
 This function polls on all file descriptors used by the curl easy handles
@@ -39,6 +40,9 @@ detected on at least one of the handles or \fItimeout_ms\fP has passed.
 The calling application may pass additional curl_waitfd structures which are
 similar to \fIpoll(2)\fP's pollfd structure to be waited on in the same call.
 
+On completion, if \fIret\fI is supplied, it will be populated with the
+number of file descriptors on which interesting events occured.
+
 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.
index 737f17ce21c0a799c8b4603774892c7f503898ab..6dcd2bac4c118335834e49aeed08ee81e63213ba 100644 (file)
@@ -157,7 +157,8 @@ CURL_EXTERN CURLMcode curl_multi_fdset(CURLM *multi_handle,
 CURL_EXTERN CURLMcode curl_multi_wait(CURLM *multi_handle,
                                       struct curl_waitfd extra_fds[],
                                       unsigned int extra_nfds,
-                                      int timeout_ms);
+                                      int timeout_ms,
+                                      int *ret);
 
  /*
   * Name:    curl_multi_perform()
index 4a1f601f60176493f1b17eb8ea5c3fc7f93ce98f..b6c327b77724f77094f9fd8084d666e34a4f9dac 100644 (file)
@@ -944,7 +944,8 @@ CURLMcode curl_multi_fdset(CURLM *multi_handle,
 CURLMcode curl_multi_wait(CURLM *multi_handle,
                           struct curl_waitfd extra_fds[],
                           unsigned int extra_nfds,
-                          int timeout_ms)
+                          int timeout_ms,
+                          int *ret)
 {
   struct Curl_multi *multi=(struct Curl_multi *)multi_handle;
   struct Curl_one_easy *easy;
@@ -1023,8 +1024,10 @@ CURLMcode curl_multi_wait(CURLM *multi_handle,
   }
 
   /* wait... */
-  Curl_poll(ufds, nfds, timeout_ms);
+  i = Curl_poll(ufds, nfds, timeout_ms);
   free(ufds);
+  if(ret)
+    *ret = i;
   return CURLM_OK;
 }
 
index c36545c52b3329d8f6a4729208caed2f09d702cd..784bdb2a244a12a78fc6082778e268c80999cc68 100644 (file)
@@ -54,12 +54,18 @@ int test(char *URL)
   abort_on_test_timeout();
 
   while(still_running) {
-    res = curl_multi_wait(multi, NULL, 0, TEST_HANG_TIMEOUT);
+    int num;
+    res = curl_multi_wait(multi, NULL, 0, TEST_HANG_TIMEOUT, &num);
     if (res != CURLM_OK) {
       printf("curl_multi_wait() returned %d\n", res);
       res = -1;
       goto test_cleanup;
     }
+    if (num != 1) {
+      printf("curl_multi_wait() returned on %d handle(s), expected 1\n", num);
+      res = -1;
+      goto test_cleanup;
+    }
 
     abort_on_test_timeout();