cURL / Mailing Lists / curl-library / Single Mail

curl-library

multi / libevent issue

From: John Dunn <John.Dunn_at_qsc.com>
Date: Thu, 20 Mar 2014 23:12:33 +0000

I'm using the curl ( 7.35.0 ) multi interface in combination with libevent ( 2.0.21 ) on Linux and am running into an issue where my CURLM stops working and all HTTP communications stop. I'm doing about 3 HTTP GETs a second all to the same IP ( not via hostname and no SSL ) and my last experiment ran about 4 hours before failing. Even though I'm using the multi interface I only have 1 HTTP request outstanding at a time.

When things are working the normal set of events looks like

- create the CURL using curl_easy_init and initialize
- add to multi via curl_multi_add_handle
- get callback to CURLMOPT_TIMERFUNCTION with 1ms timeout
- create timer in libevent
- get libevent callback in 1ms, call curl_multi_socket_action( CURL_SOCKET_TIMEOUT )
- get callback to CURLMOPT_SOCKETFUNCTION with what = CURL_POLL_IN
- create event in libevent with curl_socket_t
- get callback to CURLMOPT_TIMERFUNCTION with 1ms timeout
- create timer in libevent
- get libevent callback in 1 ms, call curl_multi_socket_action( CURL_SOCKET_TIMEOUT )
- get callback to CURLMOPT_TIMERFUNCTION with 10000ms timeout ( CURL timeout is set to 10 seconds )
- create timer in libevent
- get a whole series of libevent socket data callbacks which call curl_multi_socket_action
- get callback to CURLMOPT_SOCKETFUNCTION with what = CURL_POLL_REMOVE
- get callback to CURLMOPT_TIMERFUNCTION with -1 timeout
- kill timer

When things get wonky I never get the initial callback to CURLMOPT_TIMERFUNCTION, all I see is

- create the CURL using curl_easy_init and initialize
- add to multi via curl_multi_add_handle

The documentation states that if I have a CURLMOPT_TIMERFUNCTION set ( I do ) that callback will be called within the curl_multi_add_handle - when things fail this is not the case. Looking through the source I see a few places where that function might return silently without error ( multi.c line 2561 ) but as far as I know the CURLM is still valid.

At this point even if I keep adding things via curl_multi_add_handle nothing ever happens. I'm checking return values from all CURL API calls and never see an error. I get other libevent callbacks and if create a new CURLM it works fine with the same event base.

Here's the code I use for my multi management - http://pastebin.com/W76MxNFR
And here's the code I use to create my CURL easy - http://pastebin.com/ytmFLM4i

Thanks-

John

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2014-03-21