On Thursday 22 of April 2010 19:29:20 Constantine Sapuntzakis wrote:
> The problem is with the test.

I bet you're right.  I am a bit new to the multi interface.  I hope that 
libcurl based applications do not have the same flaw as test536 then :-)

> test536 doesn't handle maxfd == -1, which is a valid response from
> curl_multi_fdset when using the threaded resolver.
>
> I did a quick test on Mac OS X and changed the code to do the following:
>
>   if (maxfd < 0) {
>      sleep(1);
>      continue;
>   }

What about the attached patch?

> Unfortunately, this code won't compile on Windows (no sleep call).

Now it should compile fine on both systems and it seems like the fix is not 
needed on Windows because of the following quirk:

http://github.com/bagder/curl/blob/master/lib/hostthre.c#L313

> BTW, ares has better abort semantics than the threaded resolver.
> curl_*_cleanup will hang in the threaded DNS resolver until the
> resolver thread exits.

Good point.  I didn't test it so far.

Kamil
From 623aea3134a4e4b98e2893b8e3ae517ecad45a08 Mon Sep 17 00:00:00 2001
From: Kamil Dudka <[email protected]>
Date: Thu, 22 Apr 2010 20:17:02 +0200
Subject: [PATCH] test536: do not fail with threaded DNS resolver

Suggested by Constantine Sapuntzakis.
---
 tests/libtest/lib536.c |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/tests/libtest/lib536.c b/tests/libtest/lib536.c
index 04bc696..2850104 100644
--- a/tests/libtest/lib536.c
+++ b/tests/libtest/lib536.c
@@ -31,6 +31,10 @@ static CURLMcode perform(CURLM * multi)
   mp_start = tutil_tvnow();
 
   for (;;) {
+    struct timeval timeout;
+    timeout.tv_sec = 0;
+    timeout.tv_usec = 100000L; /* 100 ms */
+
     code = curl_multi_perform(multi, &handles);
     if (tutil_tvdiff(tutil_tvnow(), mp_start) >
         MULTI_PERFORM_HANG_TIMEOUT) {
@@ -53,9 +57,7 @@ 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)
+    if (select(maxfd + 1, &fdread, &fdwrite, &fdexcep, &timeout) == -1)
       return (CURLMcode) ~CURLM_OK;
   }
 
-- 
1.6.6.1

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html

Reply via email to