summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSara Golemon <sgolemon@fb.com>2012-09-15 10:38:52 -0700
committerDaniel Stenberg <daniel@haxx.se>2012-09-16 19:58:02 +0200
commitb78944146a0670b74be00e189f468adfc5fca5b7 (patch)
tree5e466784b19e166a1600ec934df0c3e2643da4e6
parent9b25b00fa3c0d57c9356fbdcec9883a3cdd16c93 (diff)
downloadgnurl-b78944146a0670b74be00e189f468adfc5fca5b7.tar.gz
gnurl-b78944146a0670b74be00e189f468adfc5fca5b7.tar.bz2
gnurl-b78944146a0670b74be00e189f468adfc5fca5b7.zip
curl_multi_wait: Add parameter to return number of active sockets
Minor change to recently introduced function. BC breaking, but since curl_multi_wait() doesn't exist in any releases that should be fine.
-rw-r--r--docs/libcurl/curl_multi_wait.36
-rw-r--r--include/curl/multi.h3
-rw-r--r--lib/multi.c7
-rw-r--r--tests/libtest/lib1500.c8
4 files changed, 19 insertions, 5 deletions
diff --git a/docs/libcurl/curl_multi_wait.3 b/docs/libcurl/curl_multi_wait.3
index 96b3c7e66..9250a77eb 100644
--- a/docs/libcurl/curl_multi_wait.3
+++ b/docs/libcurl/curl_multi_wait.3
@@ -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.
diff --git a/include/curl/multi.h b/include/curl/multi.h
index 737f17ce2..6dcd2bac4 100644
--- a/include/curl/multi.h
+++ b/include/curl/multi.h
@@ -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()
diff --git a/lib/multi.c b/lib/multi.c
index 4a1f601f6..b6c327b77 100644
--- a/lib/multi.c
+++ b/lib/multi.c
@@ -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;
}
diff --git a/tests/libtest/lib1500.c b/tests/libtest/lib1500.c
index c36545c52..784bdb2a2 100644
--- a/tests/libtest/lib1500.c
+++ b/tests/libtest/lib1500.c
@@ -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();