curl-library
Re: Issues in constraining number of open connections with curl multi interface
Date: Wed, 4 Jan 2012 16:26:51 +0100 (CET)
On Tue, 3 Jan 2012, Mukul Kedare wrote:
(Please don't top-post!)
> As suggested, we have tried out callbacks for sockets. We keep socket fd in
> our connection pool object along with the curl easy handle, this way we
> limit the number of fds with the same connection pool logic of ours.
>
> Following are our observations :
>
> 1. opensocket resolves our problem of restricting number of connections
That's at least a good start! =)
> 2. close socket is getting invoked frequently, debugged it and found out the
> close call in curl source code at lib/connect.c : line no 1013 was getting
> invoked.
>
> /*connect failed or timed out */
> Curl_closesocket(conn, sockfd);
(This is now on line 973 in my current git version)
> This occured when waitconnect() returned WAITCONN_SELECT_ERROR and
> isconnected was set to 1.
>
> What could be the reason for this?
I can only spot a single code flow for this. Line 973 is the last lines of
singleipconnect() and the code flow is:
singleipconnect() => waitconnect() => Curl_socket_ready()
in Curl_socket_ready() select() or poll() returns -1
One question is why singleipconnect() bothers to check if the connection is
connected in this situation - it seems unnecessary. Another is how it can then
think it _is_ connected and yet the Curl_socket_ready() call failed.
I guess the question is perhaps: why do you get WAITCONN_SELECT_ERROR at all?
> 3. We then implemented CURLOPT_SOCKOPTFUNCTION callback , to connect on our
> fd and observed that there were no close callback function invoked. This
> implies total control of the connection to the application and hence socket
> is not getting closed (is this correct ?). Note that, we also set KeepAlive
> option. This solves the problem mentioned in point 2.
I can't explain how CURLOPT_SOCKOPTFUNCTION makes any difference. I can't spot
that the code would lead to this effect.
-- / daniel.haxx.se ------------------------------------------------------------------- List admin: http://cool.haxx.se/list/listinfo/curl-library Etiquette: http://curl.haxx.se/mail/etiquette.htmlReceived on 2012-01-04