aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorKamil Dudka <kdudka@redhat.com>2010-04-24 12:14:21 +0200
committerKamil Dudka <kdudka@redhat.com>2010-04-24 12:14:21 +0200
commitd487ade72c5f31703ce097e8460e0225fad80348 (patch)
treefd22f7cbc0e11a42bafbc3d2099df6bb2f405ed4 /tests
parent71be565cf48f17b21eebbcde1ddba27c6e06d4c5 (diff)
test536: do not fail with threaded DNS resolver
Also tweaked comments in certain examples using curl_multi_fdset().
Diffstat (limited to 'tests')
-rw-r--r--tests/libtest/lib536.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/tests/libtest/lib536.c b/tests/libtest/lib536.c
index 04bc6965d..e0c19f661 100644
--- a/tests/libtest/lib536.c
+++ b/tests/libtest/lib536.c
@@ -21,7 +21,7 @@
static CURLMcode perform(CURLM * multi)
{
- int handles, maxfd;
+ int handles;
CURLMcode code;
fd_set fdread, fdwrite, fdexcep;
struct timeval mp_start;
@@ -31,6 +31,9 @@ static CURLMcode perform(CURLM * multi)
mp_start = tutil_tvnow();
for (;;) {
+ static struct timeval timeout = /* 100 ms */ { 0, 100000L };
+ int maxfd = -1;
+
code = curl_multi_perform(multi, &handles);
if (tutil_tvdiff(tutil_tvnow(), mp_start) >
MULTI_PERFORM_HANG_TIMEOUT) {
@@ -53,9 +56,14 @@ static CURLMcode perform(CURLM * multi)
FD_ZERO(&fdwrite);
FD_ZERO(&fdexcep);
curl_multi_fdset(multi, &fdread, &fdwrite, &fdexcep, &maxfd);
- if (maxfd < 0)
- return (CURLMcode) ~CURLM_OK;
- if (select(maxfd + 1, &fdread, &fdwrite, &fdexcep, 0) == -1)
+
+ /* In a real-world program you OF COURSE check the return code of the
+ function calls. On success, the value of maxfd is guaranteed to be
+ greater or equal than -1. We call select(maxfd + 1, ...), specially in
+ case of (maxfd == -1), we call select(0, ...), which is basically equal
+ to sleep. */
+
+ if (select(maxfd + 1, &fdread, &fdwrite, &fdexcep, &timeout) == -1)
return (CURLMcode) ~CURLM_OK;
}