cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Using curl_multi interface with epoll (Daniel Stenberg)

From: Yehezkel Horowitz <horowity_at_checkpoint.com>
Date: Tue, 8 Nov 2011 12:08:30 +0200

>> I want to use curl_multi interface along with epoll (can't use select since
>> I want to perform much more than 1024 requests in parallel).
>>
>> My problem is that I can't get the "new" sockets that I need to add to the
>> epoll_ctl, just the whole set of fds (by using curl_multi_fdset).

>Right, the original multi interface API was never made for event based systems but was instead perhaps a bit naively designed to rely on select().

>You need to switch over to the curl_multi_socket_action() paradigm to get the event based style going. http://curl.haxx.se/libcurl/c/hiperfifo.html is an example using it. That API tells your application about each file descriptor to wait for and you then tell libcurl for each activity on one of the descriptors that belong to libcurl.

I looked at the hipefifo example and it helped me a lot, thanks.

I still left with some questions and comments:

1. The example use curl_multi_socket API and not curl_multi_socket_action, I think it's good idea to update it.

2. Something is not clear to me about the TIMER API:
I understand the multi_timer_cb called whenever there is a change in the timeout and that it should schedule a call to timer_cb after the timeout reached.
I don't understand if this should be periodic call or not (should the timer_cb schedule another call to itself after the timeout is reached again)?
If it should be periodic, I think it'll be quite busy since I got timeout of just 1ms!

3. I get into the following problem:
Few jobs are running but till the next job will come, they will didn't get progress, after the next job is initiated - the running jobs get progress.

This problem is solved by calling to curl_multi_socket_all(multi, &still_running) instead of curl_multi_socket_action(multi, CURL_SOCKET_TIMEOUT, &still_runing).
Did any one know about such problem?

4. Is there a strict order between the following?
a. CURLMOPT_SOCKETFUNCTION is call to close the socket (with CURL_POLL_REMOVE)
b. CURLOPT_HEADERFUNCTION and CURLOPT_WRITEFUNCTION of the easy handle that use the socket are called to write the response headers and body?

TIA

Yehezkel

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2011-11-08