cURL / Mailing Lists / curl-library / Single Mail

curl-library

RE: CURLE_OPERATION_TIMEDOUT using curl_multi_socket_action

From: Paras S <livetestid_at_live.in>
Date: Sun, 17 Mar 2013 09:53:06 +0530

> I don't know nor use NSPR so I can't comment on all subtle details here. But
> really, you're using epoll in the example so that is what you should rather
> focus more on using correctly here.
>
> Let's try to straighten out everything from the ground up, as this source code
> is very VERY far from a proper use of libcurl. It is kind of amazing that it
> works to any degree at all!
I was exploring the possibility of using multi curl using an existing thread pool architecture, and even though there is a gap between the intended use and my implementation, the idea was fascinating.

> 1 - your code doesn't use CURLMOPT_TIMERFUNCTION[1] which in the case of
> the socket_action API is just wrong unless you have a very specfic idea
> on how to survive without it and knowledge about why.
I assumed I would not be needing CURLMOPT_TIMERFUNCTION because:
1. epoll tells me when read/write operation on a socket is ready. When it does, I will call curl_multi_socket_action for the particular socket.
2. I am adding the job to a timer queue. Of course this is less than ideal, the API supplies me with a "global" timeout, whereas I have implemented a per job timeout. Again, this work-around is to try re-using the existing code.

> 2 - why use a thread pool at all in this case? the multi API handles
> parallell connections in a single thread. You only make things harder for
> yourself by mixing threads into the game like this.
Since I was trying to re-use the architecture, it was easier for me implement this way. In the example function curl_calls, the call to curl_multi_add_handle can be conditional. I could do it based on the result of some other operations.

> 3 - your socket_callback doesn't _do_ anything??? You are supposed to "catch"
> the socket in there and subscribe to notifications from your event
> library on that sockets (and that specific "action").
I set the appropriate variables in the callback, and subscribe to notifications in epoll_calls.

> 4 - you're using an event-based API so call libcurl when events trigger!
epoll_calls does just that. It calls PR_QueueJob which in-turn calls curl_calls which calls curl_multi_socket_action.

By the way, did you happen to go through the other program (curl_reuse_issue.cc), which demonstrates that curl tries to create another connection even though one has already been established?

Thanks,
Paras.
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2013-03-17