cURL / Mailing Lists / curl-library / Single Mail

curl-library

curl_multi and failed connections

From: Apurva Mehta <apurva_at_mathmeth.com>
Date: Tue, 21 Sep 2010 14:09:00 -0700

Hello,

I am not sure I have seen this discussed already, so I will just
throw it out. Please direct me to existing literature if this issue
has been encountered before.

* * *

First, a description of the problem.

[ In the following, the libcurl version is 7.19.4 and it is running on
RHEL4u7 (linux kernel 2.6.9-80). ]

I have noticed that my application using libcurl gets into an endless
loop in the following code segment:

        while (num_running != 0){
                while ( CURLM_CALL_MULTI_PERFORM == curl_multi_perform
(multi_handle, &num_running));
                wait_for_data (multi_handle);
       }

The `wait_for_data' function uses curl_multi_fdset and `select' to
wait for data on the sockets associated with the multi_handle. It
returns as soon as select returns and no processing is done on the
return value of select. The timeout on the select call is 1 second.

I know that the application spins endlessly in that segment because
the use of strace and gdb on a running process. An strace process
yields the following :

    1285102803.875749 clock_gettime(CLOCK_MONOTONIC, {580769, 82785000}) = 0
    1285102803.875777 select(11, [10], [10], [], {1, 0}) = 2 (in [10],
out [10], left {1, 0})
    1285102803.875814 clock_gettime(CLOCK_MONOTONIC, {580769, 82851000}) = 0
    1285102803.875843 select(11, [10], [10], [], {1, 0}) = 2 (in [10],
out [10], left {1, 0})
    1285102803.875880 clock_gettime(CLOCK_MONOTONIC, {580769, 82916000}) = 0
    1285102803.875908 select(11, [10], [10], [], {1, 0}) = 2 (in [10],
out [10], left {1, 0})
    1285102803.875945 clock_gettime(CLOCK_MONOTONIC, {580769, 82981000}) = 0
    1285102803.875974 select(11, [10], [10], [], {1, 0}) = 2 (in [10],
out [10], left {1, 0})

File descriptor 10 is a http connection to a web server which is in
CLOSE_WAIT state . Looking at the access logs of the server in
question, I see no trace of the http request made by this process.
That suggests that there is some connection error along the way.

* * *

So it seems like there was an error in connection establishment and
somehow libcurl cannot detect that and keeps spinning expecting data
on the socket. The process in question has been spinning for several
hours now.

Is this a known issue? Are there any suggested workarounds?

Thanks,
Apurva
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2010-09-21