On Fri, 20 Mar 2009, Chad Monroe wrote:

* Expire cleared
* Connection #0 to host 10.4.4.204 left intact

About ~10 seconds later the server sends another packet on this socket, poll() fires, and my application calls curl_multi_perform(). I'm guessing that because the transfer is finished, curl_multi_perform() does not perform any action on this socket as I get stuck in this loop forever. poll() continuously fires with an event of POLLIN and curl_multi_perform() gets called. curl_multi_fdset() still reports the descriptor as in use at this time.

I don't get it. If the transfer is complete and the socket is no longer used by any active easy handle, why does it still get used in poll() ? The moment that transfer was completed, libcurl will of course no longer use that socket nor care about it if something arrives on it.

Looking at the libcurl code, it looks like sockets are only closed upon error, or when calling curl_multi_cleanup().

Yes, or if the server says so or just closes it, or if you tell libcurl to not re-use the handle for that specific transfer (CURLOPT_FORBID_REUSE).

1.) retrieve all sockets used by a specific easy handle so I can close them manually
2.) tell libcurl to close all sockets associated with an easy handle

Neither option exist but for the reason that they really shouldn't be needed. You _either_ don't want the connection to be kept around and re-use and then you tell libcurl to not re-use it, or you want it to be re-use and then you want it kept open as much as possible (of course limited by the limiter for max number of connections).

And recently libcurl has also got a lot better to kill connections that died recently, even before they are attempted to get re-used so thus it will now keep less sockets in TIME_WAIT or other "almost-dead" states.

Or is there some other better way to solve my problem?

The primary question is simply why you poll() on sockets not used by libcurl any longer?

--

 / daniel.haxx.se

Reply via email to