On 9/22/2014 4:42 PM, arif khan wrote:

    Date: Sat, 20 Sep 2014 23:35:38 +0200 (CEST)
    From: Daniel Stenberg <[email protected] <mailto:[email protected]>>

    On Fri, 19 Sep 2014, arif khan wrote:

    > To narrow down the problem I wrote a multi-threaded app which
    runs 100
    > threads, in each thread if requests http page in a loop of range
    1000. In
    > total 100000 requests, I can see 6-10 requests fails with above
    error.

    Sounds like it could potentially be running out of some resources?
    I think it
    would help if you figured out exactly which function call that returns
    failure, as I suspect it is actually the underlying getaddrinfo()
    that returns
    failure and then it feels like the problem is in Windows and not
    in libcurl.


Thank you for comments.

Yes it is getaddrinfo(). I will try to find the problem if this is something with running out of resource.

Is it still supported to build the way arif is building using the makefile in the winbuild directory? I'm using the projects/Windows build. Is one better than the other?

assuming threaded resolver then the new thread is created and calls getaddrinfo_thread(),
getaddrinfo_thread() calls Curl_getaddrinfo_ex() at asyn-thread.c:279,
Curl_getaddrinfo_ex() calls getaddrinfo() at curl_addrinfo.c:128.

Are you sure it's getaddrinfo arif? I wonder if getaddrinfo() is truly thread safe in Windows. I've read a few contradictions but they're anecdotal. What version of Windows are you using? Attached is a patch that will dump relevant info to stderr when getaddrinfo fails. The patch is based on a later version of curl (1ccfabb 2014-09-10) than the one you are using so it's possible it won't apply clean. In that case look for the if(error) after getaddrinfo() call in Curl_getaddrinfo_ex(). Also does the problem happen when you build x86?
diff --git a/lib/curl_addrinfo.c b/lib/curl_addrinfo.c
index 10652c6..e0e024c 100644
--- a/lib/curl_addrinfo.c
+++ b/lib/curl_addrinfo.c
@@ -127,7 +127,15 @@ Curl_getaddrinfo_ex(const char *nodename,
 
   error = getaddrinfo(nodename, servname, hints, &aihead);
   if(error)
+  {
+    fprintf(stderr, "\ngetaddrinfo() failed on thread %u with error %d.\n",
+        GetCurrentThreadId(), error);
+    fprintf(stderr, "nodename: %s\n", nodename ? nodename : "(null)");
+    fprintf(stderr, "servname: %s\n", servname ? servname : "(null)");
+    fprintf(stderr, "hints->ai_family: %d\n", hints->ai_family);
+    fprintf(stderr, "hints->ai_socktype: %d\n\n", hints->ai_socktype);
     return error;
+  }
 
   /* traverse the addrinfo list */
 
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html

Reply via email to