cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: adding easy handles when using curl_multi_socket*

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Wed, 30 Apr 2008 00:13:22 +0200 (CEST)

On Tue, 29 Apr 2008, koettermarkus_at_gmx.de wrote:

>> That libcurl function can and will deal with multiple connections so the
>> CURLM_CALL_MULTI_PERFORM may be due to things happening on other
>> connections/sockets!#
>
> I hope curl_multi_socket_action won't return CURLM_CALL_MULTI_PERFORM for
> actions on other sockets than the one I passed.

It can, as it will take care of timer actions on other sockets if need be. See
the multi_socket() function for details.

> In this case, I only have a single connection at a time, therefore this is
> not causing of the problem anyway.

Ah, but that makes the problem easier to solve then. It must mean that
multi_runsingle() on multi.c:1725 (rough line number due to my local changes)
returns CURLM_CALL_MULTI_PERFORM and then a few lines further down
singlesocket() gets called and that must be calling the callback with REMOVE
for that socket...

>> socket again and then you'll get a return code back since that socket is
>> then closed already! :-/
>
> Not closed, just not in the hashtable any longer?

Either way, that part of the code makes no distinction. The socket is no
longer being used so it shouldn't be monitored anymore.

> singlesocket() removes the socket and calls the socket_cb, if singlesocket
> removed the socket, do not return CURLM_CALL_MULTI_PERFORM.
>
> Either give singlesocket a return value, or use the hash table to verify the
> socket still exists in curl_multi_socket_action.

singlesocket() could very well get a return value, but what would it return?
It is used from multiple places and it can also remove multiple sockets in one
invoke!

> Define repeat, sometimes it comes up within seconds, then it takes minutes.
> I already setup my own httpd so ebay does not suffer too much traffic ;).
>
> If you need code to reproduce, I can sent you mine, it is short.

Please do!

>> Do note that load.c is not an official example source code from us.
>
> Yes, but I found nothing else using the multi_socket api, therefore ...

$ ls docs/examples/*.c | xargs grep -l curl_multi_socket
docs/examples/ghiper.c
docs/examples/hiperfifo.c

But sure, adding more examples is nothing but good!

> Once we are done, you should consider writing a public code example using
> libevent and libcurl, this is really great stuff.

Believe me, I want to improve libcurl, write docs, write tests, fix bugs and
more but time is scarce for me as for everyone else. libcurl is a group
effort, we can all contribute to it and make it better!

> If you want me to, I'd be glad to contribute.

I'd love it!

-- 
  Commercial curl and libcurl Technical Support: http://haxx.se/curl.html
Received on 2008-04-30