curl-library
in curl multi socket,in what condition the callback function of CURLMOPT_TIMERFUNCTION will be called?
Date: Wed, 14 Jan 2015 00:24:40 +0800 (CST)
Hi ,all:
I am using curl multi socket and libevent,such as the example hiperfifo, we know that Multi socket often offers a much more high-performance for applications using large numbers of simultaneous connections. So I use large amount connections in client , I register the callback of CURLMOPT_TIMERFUNCTION like this:
curl_multi_setopt(m_MultiHandle, CURLMOPT_TIMERFUNCTION, multi_timer_cb);
curl_multi_setopt(m_MultiHandle, CURLMOPT_TIMERDATA, &g);
static int multi_timer_cb(CURLM *multi, long timeout_ms, GlobalInfo *g)
{
struct timeval timeout;
(void)multi; /* unused */
timeout.tv_sec = timeout_ms/1000;
timeout.tv_usec = (timeout_ms%1000)*1000;
fprintf(stdout, "multi_timer_cb: Setting timeout to %ld ms\n", timeout_ms);
evtimer_add(g->timer_event, &timeout);
return 0;
}
in this callback function ,we just print the timeout time, and I am so confused about the log .
[2015-01-13 23:39:56.209615] DBG|CImgMultiDownload.cpp|374|timer_cb|before curl_multi_socket_action
42 [2015-01-13 23:39:56.212750] DBG|CImgMultiDownload.cpp|443|sock_cb|socket callback: s=115 e=0x1af6c90 what=OUT
43 [2015-01-13 23:39:56.212764] DBG|CImgMultiDownload.cpp|456|sock_cb|Adding data: OUT
44 [2015-01-13 23:39:56.212780] DBG|CImgMultiDownload.cpp|392|multi_timer_cb|multi_timer_cb: Setting timeout to 997 ms <- first called
45 [2015-01-13 23:39:56.212795] DBG|CImgMultiDownload.cpp|376|timer_cb|after curl_multi_socket_action
46 [2015-01-13 23:39:56.212807] DBG|CImgMultiDownload.cpp|226|check_multi_info|REMAINING: 1
47 [2015-01-13 23:39:56.213652] DBG|CImgMultiDownload.cpp|392|multi_timer_cb|multi_timer_cb: Setting timeout to 997 ms <- second called
48 [2015-01-13 23:39:56.213665] DBG|CImgMultiDownload.cpp|226|check_multi_info|REMAINING: 1
49 [2015-01-13 23:39:57.211260] DBG|CImgMultiDownload.cpp|374|timer_cb|before curl_multi_socket_action
50 [2015-01-13 23:39:57.211287] DBG|CImgMultiDownload.cpp|443|sock_cb|socket callback: s=115 e=0x1af6c90 what=REMOVE <- here remove the socket,why? I thought here shou be sent http header to server
51 [2015-01-13 23:39:57.211300] DBG|CImgMultiDownload.cpp|447|sock_cb|remove socket fd!
52 [2015-01-13 23:39:57.211311] DBG|CImgMultiDownload.cpp|376|timer_cb|after curl_multi_socket_action
why the callback function of multi_timer_cb called twice??
and my second question is :In what condition ,the callback function multi_timer_cb will be called ?
Thanks a lot!
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2015-01-13