curl-library
Re: Query regarding multiple easy handles on same socket
Date: Wed, 19 Jul 2017 19:42:53 +0200 (CEST)
On Tue, 18 Jul 2017, srinivasa srikanth podila via curl-library wrote:
> I am doing it on scale of 10000 requests over 1000 connections with a HTTP
> Get of 200kb.txt. Upon the socket close[connection reset] by Server, i see
> a delayed POLL_REMOVE notification for some sockfds from libcurl and the
> libuv is aborting due to BAD_FILE_DESCRIPTOR for those invalidated sockfd
> by libcurl.
>
> Could you please let me know the ideal way of handling these erroneous
> scenarios in my application?
I don't understand the error you're talking about. Can you elaborate on this
delayed notifiction, what it is and how it happens when what is going on on
the TCP connection?
> I tried using CURLOPT_OPENSOCKETFUNCTION and CURLOPT_CLOSESOCKETFUNCTION to
> maintain sockets manually using the multi-handle. However i am getting
> close_socket notification for every single request, and i cannot close the
> socket as there could be other easy handles using the same socket, So i am
> unable to figure out a way to use multiple-requests over the same socket .
This also confuses me. When libcurl calls the open socket callback it needs a
new socket and when it calls the close socket one the socket is not used by
libcurl anymore. So yes, you can indeed close it. (And without the callbacks
libcurl will of course do that by itself instead.)
libcurl will not close a socket that is associated with a connection that it
can and intend to reuse. It will only close sockets/connections when they
can't be reused anymore.
> I feel if there is a way that libcurl notifies application with POLL_REMOVE
> when the sockfd is active, it would be great.
POLL_REMOVE to the application doesn't mean that the socket gets closed. It
means that the application can stop monitoring the socket (for now).
-- / daniel.haxx.se ------------------------------------------------------------------- Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library Etiquette: https://curl.haxx.se/mail/etiquette.htmlReceived on 2017-07-19