aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2014-05-15 20:43:32 +0200
committerDaniel Stenberg <daniel@haxx.se>2014-05-15 21:28:19 +0200
commit84bd19ffd4374fd7b4fbe5a0ee0ecbf263d52ede (patch)
tree3262cadb8d5a84edfa0ce7b7e758309f4d56861c
parent678239df547bacf762dea664dabf1ce207f0a048 (diff)
timers: fix timer regression involving redirects / reconnects
In commit 0b3750b5c23c25f (released in 7.36.0) we fixed a timeout issue but instead broke the timings. To fix this, I introduce a new timestamp to use for the timeouts and restored the previous timestamp and timestamp position so that the old timer functionality is restored. In addition to that, that change also broke connection timeouts for when more than one connect was used (as it would then count the total time from the first connect and not for the most recent one). Now Curl_timeleft() has been modified so that it checks against different start times depending on which timeout it checks. Test 1303 is updated accordingly. Bug: http://curl.haxx.se/mail/lib-2014-05/0147.html Reported-by: Ryan Braud
-rw-r--r--lib/connect.c7
-rw-r--r--lib/multi.c3
-rw-r--r--lib/progress.c8
-rw-r--r--lib/progress.h5
-rw-r--r--lib/urldata.h1
-rw-r--r--tests/unit/unit1303.c4
6 files changed, 21 insertions, 7 deletions
diff --git a/lib/connect.c b/lib/connect.c
index b35c36c00..ca6e3466c 100644
--- a/lib/connect.c
+++ b/lib/connect.c
@@ -224,7 +224,12 @@ long Curl_timeleft(struct SessionHandle *data,
}
/* subtract elapsed time */
- timeout_ms -= Curl_tvdiff(*nowp, data->progress.t_startsingle);
+ if(duringconnect)
+ /* since this most recent connect started */
+ timeout_ms -= Curl_tvdiff(*nowp, data->progress.t_startsingle);
+ else
+ /* since the entire operation started */
+ timeout_ms -= Curl_tvdiff(*nowp, data->progress.t_startop);
if(!timeout_ms)
/* avoid returning 0 as that means no timeout! */
return -1;
diff --git a/lib/multi.c b/lib/multi.c
index c52db9625..72fde7439 100644
--- a/lib/multi.c
+++ b/lib/multi.c
@@ -1026,7 +1026,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
if(CURLE_OK == data->result) {
/* after init, go CONNECT */
multistate(data, CURLM_STATE_CONNECT);
- Curl_pgrsTime(data, TIMER_STARTSINGLE);
+ Curl_pgrsTime(data, TIMER_STARTOP);
result = CURLM_CALL_MULTI_PERFORM;
}
break;
@@ -1038,6 +1038,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
case CURLM_STATE_CONNECT:
/* Connect. We want to get a connection identifier filled in. */
+ Curl_pgrsTime(data, TIMER_STARTSINGLE);
data->result = Curl_connect(data, &data->easy_conn,
&async, &protocol_connect);
if(CURLE_NO_CONNECTION_AVAILABLE == data->result) {
diff --git a/lib/progress.c b/lib/progress.c
index a242f8bc2..e6a8d825a 100644
--- a/lib/progress.c
+++ b/lib/progress.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2013, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -172,8 +172,12 @@ void Curl_pgrsTime(struct SessionHandle *data, timerid timer)
case TIMER_NONE:
/* mistake filter */
break;
+ case TIMER_STARTOP:
+ /* This is set at the start of a transfer */
+ data->progress.t_startop = now;
+ break;
case TIMER_STARTSINGLE:
- /* This is set at the start of a single fetch */
+ /* This is set at the start of each single fetch */
data->progress.t_startsingle = now;
break;
diff --git a/lib/progress.h b/lib/progress.h
index f97fef996..a1e6f1a23 100644
--- a/lib/progress.h
+++ b/lib/progress.h
@@ -7,7 +7,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2012, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -27,13 +27,14 @@
typedef enum {
TIMER_NONE,
+ TIMER_STARTOP,
+ TIMER_STARTSINGLE,
TIMER_NAMELOOKUP,
TIMER_CONNECT,
TIMER_APPCONNECT,
TIMER_PRETRANSFER,
TIMER_STARTTRANSFER,
TIMER_POSTRANSFER,
- TIMER_STARTSINGLE,
TIMER_STARTACCEPT,
TIMER_REDIRECT,
TIMER_LAST /* must be last */
diff --git a/lib/urldata.h b/lib/urldata.h
index e62ea1930..640cbb1c6 100644
--- a/lib/urldata.h
+++ b/lib/urldata.h
@@ -1135,6 +1135,7 @@ struct Progress {
struct timeval start;
struct timeval t_startsingle;
+ struct timeval t_startop;
struct timeval t_acceptdata;
#define CURR_TIME (5+1) /* 6 entries for 5 seconds */
diff --git a/tests/unit/unit1303.c b/tests/unit/unit1303.c
index 2e4f23096..b48a6250c 100644
--- a/tests/unit/unit1303.c
+++ b/tests/unit/unit1303.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -131,6 +131,8 @@ const struct timetest run[] = {
/* this is the pretended start time of the transfer */
data->progress.t_startsingle.tv_sec = BASE;
data->progress.t_startsingle.tv_usec = 0;
+data->progress.t_startop.tv_sec = BASE;
+data->progress.t_startop.tv_usec = 0;
for(i=0; i < sizeof(run)/sizeof(run[0]); i++) {
NOW(run[i].now_s, run[i].now_us);