aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorRyan Winograd <ryan@thewinograds.com>2017-06-21 12:15:46 -0500
committerDaniel Stenberg <daniel@haxx.se>2017-08-15 18:58:31 +0200
commit43d036e72488b4be5f48aaec9278a55dc22cb556 (patch)
tree32de6e2fd9ac79fac4fc5cc9ba75f4d2c614bd84 /lib
parent0969901eb9a2efb9f204a48c2538925d27944444 (diff)
progress: Track total times following redirects
Update the progress timers `t_nslookup`, `t_connect`, `t_appconnect`, `t_pretransfer`, and `t_starttransfer` to track the total times for these activities when a redirect is followed. Previously, only the times for the most recent request would be tracked. Related changes: - Rename `Curl_pgrsResetTimesSizes` to `Curl_pgrsResetTransferSizes` now that the function only resets transfer sizes and no longer modifies any of the progress timers. - Add a bool to the `Progress` struct that is used to prevent double-counting `t_starttransfer` times. Added test case 1399. Fixes #522 and Known Bug 1.8 Closes #1602 Reported-by: joshhe on github
Diffstat (limited to 'lib')
-rw-r--r--lib/getinfo.c1
-rw-r--r--lib/progress.c16
-rw-r--r--lib/progress.h2
-rw-r--r--lib/transfer.c4
-rw-r--r--lib/urldata.h2
5 files changed, 13 insertions, 12 deletions
diff --git a/lib/getinfo.c b/lib/getinfo.c
index dc3a107e9..9c6f3b731 100644
--- a/lib/getinfo.c
+++ b/lib/getinfo.c
@@ -54,6 +54,7 @@ CURLcode Curl_initinfo(struct Curl_easy *data)
pro->t_starttransfer = 0;
pro->timespent = 0;
pro->t_redirect = 0;
+ pro->is_t_startransfer_set = false;
info->httpcode = 0;
info->httpproxycode = 0;
diff --git a/lib/progress.c b/lib/progress.c
index 740ff2887..2f80704ae 100644
--- a/lib/progress.c
+++ b/lib/progress.c
@@ -149,14 +149,9 @@ int Curl_pgrsDone(struct connectdata *conn)
return 0;
}
-/* reset all times except redirect, and reset the known transfer sizes */
-void Curl_pgrsResetTimesSizes(struct Curl_easy *data)
+/* reset the known transfer sizes */
+void Curl_pgrsResetTransferSizes(struct Curl_easy *data)
{
- data->progress.t_nslookup = 0;
- data->progress.t_connect = 0;
- data->progress.t_pretransfer = 0;
- data->progress.t_starttransfer = 0;
-
Curl_pgrsSetDownloadSize(data, -1);
Curl_pgrsSetUploadSize(data, -1);
}
@@ -181,6 +176,7 @@ void Curl_pgrsTime(struct Curl_easy *data, timerid timer)
case TIMER_STARTSINGLE:
/* This is set at the start of each single fetch */
data->progress.t_startsingle = now;
+ data->progress.is_t_startransfer_set = false;
break;
case TIMER_STARTACCEPT:
data->progress.t_acceptdata = now;
@@ -205,10 +201,11 @@ void Curl_pgrsTime(struct Curl_easy *data, timerid timer)
* This prevents repeated invocations of the function from incorrectly
* changing the t_starttransfer time.
*/
- if (*delta > data->progress.t_redirect) {
+ if(data->progress.is_t_startransfer_set) {
return;
}
else {
+ data->progress.is_t_startransfer_set = true;
break;
}
case TIMER_POSTRANSFER:
@@ -222,7 +219,7 @@ void Curl_pgrsTime(struct Curl_easy *data, timerid timer)
time_t us = Curl_tvdiff_us(now, data->progress.t_startsingle);
if(!us)
us++; /* make sure at least one microsecond passed */
- *delta = us;
+ *delta += us;
}
}
@@ -230,6 +227,7 @@ void Curl_pgrsStartNow(struct Curl_easy *data)
{
data->progress.speeder_c = 0; /* reset the progress meter display */
data->progress.start = Curl_tvnow();
+ data->progress.is_t_startransfer_set = false;
data->progress.ul_limit_start.tv_sec = 0;
data->progress.ul_limit_start.tv_usec = 0;
data->progress.dl_limit_start.tv_sec = 0;
diff --git a/lib/progress.h b/lib/progress.h
index ed57e3368..9333ab25c 100644
--- a/lib/progress.h
+++ b/lib/progress.h
@@ -47,7 +47,7 @@ void Curl_pgrsSetUploadSize(struct Curl_easy *data, curl_off_t size);
void Curl_pgrsSetDownloadCounter(struct Curl_easy *data, curl_off_t size);
void Curl_pgrsSetUploadCounter(struct Curl_easy *data, curl_off_t size);
int Curl_pgrsUpdate(struct connectdata *);
-void Curl_pgrsResetTimesSizes(struct Curl_easy *data);
+void Curl_pgrsResetTransferSizes(struct Curl_easy *data);
void Curl_pgrsTime(struct Curl_easy *data, timerid timer);
long Curl_pgrsLimitWaitTime(curl_off_t cursize,
curl_off_t startsize,
diff --git a/lib/transfer.c b/lib/transfer.c
index 3537b58c6..e7625ef77 100644
--- a/lib/transfer.c
+++ b/lib/transfer.c
@@ -1345,7 +1345,7 @@ CURLcode Curl_pretransfer(struct Curl_easy *data)
#endif
Curl_initinfo(data); /* reset session-specific information "variables" */
- Curl_pgrsResetTimesSizes(data);
+ Curl_pgrsResetTransferSizes(data);
Curl_pgrsStartNow(data);
if(data->set.timeout)
@@ -1883,7 +1883,7 @@ CURLcode Curl_follow(struct Curl_easy *data,
break;
}
Curl_pgrsTime(data, TIMER_REDIRECT);
- Curl_pgrsResetTimesSizes(data);
+ Curl_pgrsResetTransferSizes(data);
return CURLE_OK;
#endif /* CURL_DISABLE_HTTP */
diff --git a/lib/urldata.h b/lib/urldata.h
index b4f18e7da..e45baff17 100644
--- a/lib/urldata.h
+++ b/lib/urldata.h
@@ -1259,6 +1259,8 @@ struct Progress {
struct curltime t_startop;
struct curltime t_acceptdata;
+ bool is_t_startransfer_set;
+
/* upload speed limit */
struct curltime ul_limit_start;
curl_off_t ul_limit_size;