Hello,

I am about to experimentally switch libcurl in rawhide Fedora to use
POSIX threaded DNS resolver.  I ugly hacked configure.ac to enable this 
feature.  That's the first patch.  Then I had problem with permanently
failing test536.  The failure seems to be caused by insufficiently
implemented function Curl_resolv_getsock() in hostthre.c.  I was not 
successful in coming up with a proper implementation, thus decided to
use another ugly hack for now.  That's the second patch.

Now I'll do some smoke tests, build the packages for rawhide, and
perhaps come with some more feedback later on.

Kamil
 lib/multi.c |   17 ++++++++++++++++-
 1 files changed, 16 insertions(+), 1 deletions(-)

diff --git a/lib/multi.c b/lib/multi.c
index 476cb81..74eb0f4 100644
--- a/lib/multi.c
+++ b/lib/multi.c
@@ -933,9 +933,16 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
         easy->result = addHandleToSendOrPendPipeline(easy->easy_handle,
                                                      easy->easy_conn);
         if(CURLE_OK == easy->result) {
-          if(async)
+          if(async) {
             /* We're now waiting for an asynchronous name lookup */
             multistate(easy, CURLM_STATE_WAITRESOLVE);
+#ifdef USE_THREADS_POSIX
+            /* Curl_resolv_getsock() is not properly implemented in case
+             * we use POSIX threaded DNS resolver, we have to hang */
+            result = CURLM_CALL_MULTI_PERFORM;
+            break;
+#endif
+          }
           else {
             /* after the connect has been sent off, go WAITCONNECT unless the
                protocol connect is already done and we can go directly to
@@ -1003,6 +1010,14 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
         disconnect_conn = TRUE;
         break;
       }
+#ifdef USE_THREADS_POSIX
+      /* Curl_resolv_getsock() is not properly implemented yet in case
+       * we use POSIX threaded DNS resolver, we have to hang */
+      Curl_socket_ready(CURL_SOCKET_BAD, CURL_SOCKET_BAD, 100 /* ms */);
+      result = CURLM_CALL_MULTI_PERFORM;
+      break;
+#endif
+
     }
     break;
 
 configure.ac |   14 +++++++++++++-
 1 files changed, 13 insertions(+), 1 deletions(-)

diff --git a/configure.ac b/configure.ac
index 39cc418..4892fda 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2285,6 +2285,18 @@ AM_CONDITIONAL(USE_MANUAL, test x"$USE_MANUAL" = x1)
 CURL_CHECK_LIB_ARES
 AM_CONDITIONAL(USE_EMBEDDED_ARES, test x$embedded_ares = xyes)
 
+AC_CHECK_HEADER(pthread.h,
+  [ AC_DEFINE(HAVE_PTHREAD_H, 1, [if you have <pthread.h>])
+    save_CFLAGS="$CFLAGS"
+    CFLAGS="$CFLAGS -pthread"
+    AC_CHECK_LIB(pthread, pthread_create,
+      [ AC_MSG_NOTICE([using POSIX threaded DNS lookup])
+        AC_DEFINE(USE_THREADS_POSIX, 1, [if you want POSIX threaded DNS lookup])
+        USE_THREADS_POSIX=1
+      ],
+      [ CFLAGS="$save_CFLAGS"])
+  ])
+
 dnl ************************************************************
 dnl disable verbose text strings
 dnl
@@ -2478,7 +2490,7 @@ fi
 if test "x$HAVE_LIBZ" = "x1"; then
   SUPPORT_FEATURES="$SUPPORT_FEATURES libz"
 fi
-if test "x$USE_ARES" = "x1"; then
+if test "x$USE_ARES" = "x1" -o "x$USE_THREADS_POSIX" = "x1"; then
   SUPPORT_FEATURES="$SUPPORT_FEATURES AsynchDNS"
 fi
 if test "x$IDN_ENABLED" = "x1"; then
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html

Reply via email to