curl-library
curl_multi_perform slow (timeout)
Date: Fri, 10 Oct 2008 18:32:05 +0200
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-10