cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: curl_multi_perform slow (timeout)

From: Dino Puller <dino.puller_at_edalab.it>
Date: Mon, 13 Oct 2008 12:29:30 +0200

I protected all curl_multi_xxx functions with a mutex, and it seems
that it works better, anyway the problem still there. Curl may need
9-10 seconds to accomplish a transfer . It's seems that it's a kind of
timed out event because the time that it takes it's always between 9
to 10 seconds, when it can't transfer the file immediately.

Mon, 13 Oct 2008 12:16:25 +0200 DEBUG curl_multi_add_handle type RU
Mon, 13 Oct 2008 12:16:25 +0200 DEBUG curl_multi_add_handle type VI
Mon, 13 Oct 2008 12:16:25 +0200 INFO Rse Message VI transferred
       <---- OK
Mon, 13 Oct 2008 12:16:35 +0200 DEBUG curl_multi_add_handle type VI
Mon, 13 Oct 2008 12:16:35 +0200 INFO Rse Message RU transferred
     <----- 10 sec!!!

any suggestion? May i debug libcurl, where i should place my breakpoints?

tnx,
   Dino Puller

2008/10/10 Dino Puller <dino.puller_at_edalab.it>:
> hi all,
> i've used the easy interface without a problem, now i turned to
> multi because i need async calls and i fell in a very slow performance
> till various timeout.
> I've a thread in polling that calls curl_multi_perform (twice if
> needed) curl_multi_fdset, select and finally curl_multi_info_read, and
> another thread that call curl_multi_add_handle as needed.
> Here's the simplified code:
>
> while (m_running){
> FD_ZERO(&fdread);
> FD_ZERO(&fdwrite);
> FD_ZERO(&fdexcep);
>
> err = curl_multi_perform(_this->multi_handle, &running_handles);
> if (err == CURLM_CALL_MULTI_PERFORM)
> err = curl_multi_perform(_this->multi_handle, &running_handles);
>
> // get file descriptors from the transfers
> maxfd = 0;
> err = curl_multi_fdset(_this->multi_handle, &fdread, &fdwrite,
> &fdexcep, &maxfd);
> if (maxfd >= 0){
> // set a suitable timeout to fail on
> struct timeval timeout;
> timeout.tv_sec = 1; // second
> timeout.tv_usec = 0;
> int rc = select(maxfd + 1, &fdread, &fdwrite, &fdexcep, &timeout);
> if (rc > 0){
> err = curl_multi_perform(_this->multi_handle, &running_handles);
> if (err == CURLM_CALL_MULTI_PERFORM)
> err = curl_multi_perform(_this->multi_handle, &running_handles);
>
> CURLMsg *msg =
> curl_multi_info_read(_this->multi_handle,&running_handles);
> if (msg && msg->msg == CURLMSG_DONE){ // transfer completed
> do_something();
> curl_multi_remove_handle(_this->multi_handle, msg->easy_handle);
> }
> }
> }
> }
>
> It's seems that the first curl_multi_perform may wait till 9sec.
> Using the callback CURLMOPT_TIMERFUNCTION i can see a Timeout, anyway
> it's seems not important which value i pass to curl_multi_timeout()
> function.
>
> The program simply send an http message via Post, the bigger is no
> more than 1,5Kbyte, and receive a small xml response.
> 9 sec are simply too much.
>
> libcurl version tested: 7.19.0 and 7.18.2
>
> Any idea or workaround?
>
> tnx,
> Dino Puller
>
Received on 2008-10-13