cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re:Re: I set the timeout to 2 seconds , but it consume 6 seconds,and then return the error code 28

From: À¼Ìì <lantian0811_at_163.com>
Date: Mon, 11 Jul 2016 15:03:41 +0800 (CST)

libcurl version?
------curl-7.30.0
Which name resolver backend did it use?
------ I use ip to download picture , like this 10.x.x.x
On which platform did you run this?
------ linux
 What protocol did you use?
-------htttp
What exactly did libcurl do when the timeout was supposed to trigger?
------ I set timeout to 2 second, So I supposed If download time exceed 2 second, this request is timeout,so I use this api curl_easy_getinfo(easy, CURLINFO_TOTAL_TIME, &val_total_time); to get time is a little more than 2 second
Can you provide a small source code that can reproduce the problem?
curl_easy_setopt(conn->easy, CURLOPT_WRITEFUNCTION, curlCallBack::write_cb);
curl_easy_setopt(conn->easy, CURLOPT_WRITEDATA, conn->mc);
curl_easy_setopt(conn->easy, CURLOPT_URL, strUrl.c_str());
//curl_easy_setopt(conn->easy, CURLOPT_VERBOSE, 1L);
//curl_easy_setopt(conn->easy, CURLOPT_ERRORBUFFER, conn->error);
curl_easy_setopt(conn->easy, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
curl_easy_setopt(conn->easy, CURLOPT_PRIVATE, conn);
curl_easy_setopt(conn->easy, CURLOPT_TIMEOUT, 2);
//curl_easy_setopt(conn->easy, CURLOPT_CONNECTTIMEOUT, 1);
curl_easy_setopt(conn->easy, CURLOPT_FOLLOWLOCATION, 1);

and get the result :
while ((msg = curl_multi_info_read(g->multi, &msgs_left)))
{
//printf("msgs_left:%d\n",msgs_left);
if (msg->msg == CURLMSG_DONE)
{
//Attr_API(2164834,1);
easy = msg->easy_handle;
 res = msg->data.result;
 curl_easy_getinfo(easy, CURLINFO_PRIVATE, &conn);
 curl_easy_getinfo(easy, CURLINFO_EFFECTIVE_URL, &eff_url);
double val_size,val_total_time,val_nameloopup_time,val_connect_time;
//curl_easy_getinfo(easy, CURLINFO_TOTAL_TIME, &val);
//total_time+=val;
curl_easy_getinfo(easy, CURLINFO_SIZE_DOWNLOAD, &val_size);
gDownloadTotalSize+=(uint64_t)val_size;
curl_easy_getinfo(easy, CURLINFO_TOTAL_TIME, &val_total_time);
gDownloadTotalTime+=(uint64_t)val_total_time; // this place print the time is about 6 second . so I confused
//add by knuthlan 20160513 add name resolve time
curl_easy_getinfo(easy, CURLINFO_NAMELOOKUP_TIME, &val_nameloopup_time);
gNameLookupTotalTime+=(uint64_t)val_nameloopup_time;
curl_easy_getinfo(easy, CURLINFO_CONNECT_TIME, &val_connect_time);
gConnectTotalTime +=(uint64_t)val_connect_time;
                ......
}
best wishes

At 2016-07-07 04:08:20, "Daniel Stenberg" <daniel_at_haxx.se> wrote:
>On Fri, 1 Jul 2016, À¼Ìì wrote:
>
>> I use curl_easy_setopt(pCurl, CURLOPT_TIMEOUT,2);
>
>> curl_easy_getinfo(easy, CURLINFO_TOTAL_TIME, &val_total_time); to get the
>> total time elapsed, I feel strange that some request consume 6second, why ?
>
>We can't tell without much more details. It isn't supposed to work like that.
>
>libcurl version? Which name resolver backend did it use? On which platform did
>you run this? What protocol did you use? What exactly did libcurl do when the
>timeout was supposed to trigger? Can you provide a small source code that can
>reproduce the problem?
>
>--
>
> / daniel.haxx.se

-------------------------------------------------------------------
List admin: https://cool.haxx.se/list/listinfo/curl-library
Etiquette: https://curl.haxx.se/mail/etiquette.html
Received on 2016-07-11