cURL
Haxx ad
libcurl

curl's project page on SourceForge.net

Sponsors:
Haxx

cURL > Mailing List > Monthly Index > Single Mail

curl-tracker mailing list Archives

[ curl-Bugs-1326306 ] Socket descriptor leak with libcurl-multi

From: SourceForge.net <noreply_at_sourceforge.net>
Date: Fri, 14 Oct 2005 06:19:11 -0700

Bugs item #1326306, was opened at 2005-10-14 02:31
Message generated for change (Comment added) made by bagder
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=100976&aid=1326306&group_id=976

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: libcurl
Group: bad behaviour
Status: Open
Resolution: None
>Priority: 7
Submitted By: Amol Pattekar (pattekar)
Assigned to: Daniel Stenberg (bagder)
Summary: Socket descriptor leak with libcurl-multi

Initial Comment:

Hi,

The following test code reproduces the problem:

#include <string.h>
#include <curl/curl.h>
#include <unistd.h>

int main(void)
{
   CURL *curl_easy_handle;

   curl_easy_handle = curl_easy_init();
   if(curl_easy_handle) {
     curl_easy_setopt(curl_easy_handle,
CURLOPT_URL, "http://somehost.yahoo.com");
     curl_easy_setopt(curl_easy_handle,
CURLOPT_NOBODY, 1);
     curl_easy_setopt(curl_easy_handle,
CURLOPT_VERBOSE, 1);
     curl_easy_setopt(curl_easy_handle,
CURLOPT_DNS_CACHE_TIMEOUT, 0);

     CURLM *curl_multi_handle = curl_multi_init();

     for (int i=0; i<2000; i++)
       {
         curl_multi_add_handle(curl_multi_handle,
curl_easy_handle);

         int running_handles=1;

         while (running_handles)
           {
             CURLMcode code =
CURLM_CALL_MULTI_PERFORM;
             while (code ==
CURLM_CALL_MULTI_PERFORM)
               {
                 code = curl_multi_perform(curl_multi_handle,
                                           &running_handles);
               }

             if (running_handles)
               {
                 int maxFD;
                 fd_set readfds, writefds, exceptfds;
                 FD_ZERO(&readfds);
                 FD_ZERO(&writefds);
                 FD_ZERO(&exceptfds);
                 curl_multi_fdset(curl_multi_handle,
&readfds, &writefds, &exceptfds, &maxFD);

                 select(maxFD+1, &readfds, &writefds,
&exceptfds, NULL);
               }
           }

         curl_multi_remove_handle(curl_multi_handle,
curl_easy_handle);
       }
   }
   return 0;
}

Also,
1) "somehost.yahoo.com" resolves to two IP address.
One of the IP addresses experiences issues due to
which libcurl sees connection failures to that IP. The
other IP works well.
2) "somehost.yahoo.com" doesn't like persistent
connections, and returns "Connection: close" header
with every response.

I find that when libcurl experiences connection failure
with the first IP, it automatically tries the second one.
However, it doesn't close the socket descriptor that it
created to connect to the first IP, and this results in a
descriptor leak.

Thanks,

-Amol.

----------------------------------------------------------------------

>Comment By: Daniel Stenberg (bagder)
Date: 2005-10-14 15:19

Message:
Logged In: YES
user_id=1110

I'll look into it asap, but it might take a week or so. I
believe this issue still remains in 7.15.0 as I can't recall
any fix that would've changed this.

----------------------------------------------------------------------

Comment By: Amol Pattekar (pattekar)
Date: 2005-10-14 02:37

Message:
Logged In: YES
user_id=1326426

Sorry, forgot to mention: I am using libcurl-7.14.1

----------------------------------------------------------------------

You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=100976&aid=1326306&group_id=976
Received on 2005-10-14

These mail archives are generated by hypermail.

donate! Page updated November 12, 2010.
web site info

File upload with ASP.NET