cURL
Haxx ad
libcurl

curl's project page on SourceForge.net

Sponsors:
Haxx

cURL > Mailing List > Monthly Index > Single Mail

curl-tracker Archives

[curl:bugs] Re: #1243 when timeout, CURLINFO_TOTAL_TIME is not ok

From: he qin <hqin6_at_users.sf.net>
Date: Fri, 21 Jun 2013 11:34:53 +0000

It's not ok...

I found that I made a mistake. Follow the code, the callings as follows in my case:

----curl_multi_socket_action
--------multi_socket, checkall(0), s != CURL_SOCKET_TIMEOUT(0)
------------multi_runsingle, data=0x939b710, state=0, conn=(nil)
__Curl_pgrsStartNow
------------state=2, result=0, conn=(nil)
------------multi_runsingle over
------------multi_runsingle, data=0x939b710, state=2, conn=(nil)
* Closing connection 0
------------state=2, result=28, conn=(nil)
------------multi_runsingle over
--------multi_socket over
----curl_multi_socket_action end

actually, when multi_runsingle is called in the second time, the state == 2(CURLM_STATE_CONNECT) and the result == 28 (!= CURLE_OK). code here:

    if(easy->state < CURLM_STATE_COMPLETED) {
      if(CURLE_OK != easy->result) {
        /*
         * If an error was returned, and we aren't in completed state now,
         * then we go to completed and consider this transfer aborted.
         */

        /* NOTE: no attempt to disconnect connections must be made
           in the case blocks above - cleanup happens only here */

        data->state.pipe_broke = FALSE;

        if(easy->easy_conn) {//no exec...}

        else if(easy->state == CURLM_STATE_CONNECT) {//exec here
          /* Curl_connect() failed */
          (void)Curl_posttransfer(data);
        }

        multistate(easy, CURLM_STATE_COMPLETED);//set status to CURLM_STATE_COMPLETED
      }

........

  if(CURLM_STATE_COMPLETED == easy->state) { //at once, set the result to application
    /* now fill in the Curl_message with this info */
    msg = &easy->msg;

    msg->extmsg.msg = CURLMSG_DONE;
    msg->extmsg.easy_handle = data;
    msg->extmsg.data.result = easy->result;

    result = multi_addmsg(multi, msg);

    multistate(easy, CURLM_STATE_MSGSENT);
  }

In hiperfifo.c:

1. curl_multi_add_handle will call update_timer, and update_timer will call multi->timer_cb with timeout_ms=1

2.in my multi->timer_cb, I set a 1ms' timer event. And after 1ms, the libevent will wake up and exec :
       curl_multi_socket_action(multi,
            CURL_SOCKET_TIMEOUT, 0, &g->still_running);

3.after the second step, immediately I call
    while ((msg = curl_multi_info_read(g->multi, &msgs_left))) {...}

as above, the total time will be zero, because the first call of curl_multi_socket_action set its over status.

I don't know whether you know what I mean. Actually, no bug for curl, just Curl_connect() failed , curl think it's over, no time to spent, so zero is reasonable.

But I think, in my case, the return code 28 is confusing. Maybe in this case , curl return 6 or 7 will be much easier to understand for me.

       6 Couldn't resolve host. The given remote host was not resolved.

       7 Failed to connect to host.

       28 Operation timeout. The specified time-out period was reached according to the conditions.

---
** [bugs:#1243] when timeout, CURLINFO_TOTAL_TIME is not ok**
**Status:** open
**Created:** Fri Jun 07, 2013 12:46 PM UTC by he qin
**Last Updated:** Tue Jun 18, 2013 09:02 PM UTC
**Owner:** Daniel Stenberg
hi
    When I use the multi handle to process one easy handle, I set 80ms timeout for the easy handle. If timeout occur, I get the CURLINFO_TOTAL_TIME, the result is 0? why not 80ms?
Read the code, I found, when timeout occur, I call 
curl_multi_socket_action(
            multi,
            CURL_SOCKET_TIMEOUT,
            0,
            &still_running);
I see that the CURLINFO_TOTAL_TIME will be update in Curl_done->Curl_pgrsDone. But , as above code, when curl_multi_socket_action was called  use CURL_SOCKET_TIMEOUT as the second arg, curl_multi_socket_action will do nothing....(in multi_socket function , all "if" is false)
If I want to get the realtime for CURLINFO_TOTAL_TIME, how to do ?
---
Sent from sourceforge.net because you indicated interest in <https://sourceforge.net/p/curl/bugs/1243/>
To unsubscribe from further messages, please visit <https://sourceforge.net/auth/subscriptions/>
Received on 2013-06-21

These mail archives are generated by hypermail.

donate! Page updated May 06, 2013.
web site info

File upload with ASP.NET