progress: prevent resetting t_starttransfer

Prevent `Curl_pgrsTime` from modifying `t_starttransfer` when invoked
with `TIMER_STARTTRANSFER` more than once during a single request.

When a redirect occurs, this is considered a new request and
`t_starttransfer` can be updated to reflect the `t_starttransfer` time
of the redirect request.

Closes #1616

Bug: https://github.com/curl/curl/pull/1602#issuecomment-310267370
This commit is contained in:
Ryan Winograd 2017-06-26 11:51:05 -05:00 committed by Daniel Stenberg
parent ef2a9f22cc
commit f8f040e659
5 changed files with 142 additions and 2 deletions

View file

@ -161,6 +161,9 @@ void Curl_pgrsResetTimesSizes(struct Curl_easy *data)
Curl_pgrsSetUploadSize(data, -1);
}
/*
* @unittest: 1399
*/
void Curl_pgrsTime(struct Curl_easy *data, timerid timer)
{
struct timeval now = Curl_tvnow();
@ -196,7 +199,18 @@ void Curl_pgrsTime(struct Curl_easy *data, timerid timer)
break;
case TIMER_STARTTRANSFER:
delta = &data->progress.t_starttransfer;
break;
/* prevent updating t_starttransfer unless:
* 1) this is the first time we're setting t_starttransfer
* 2) a redirect has occurred since the last time t_starttransfer was set
* This prevents repeated invocations of the function from incorrectly
* changing the t_starttransfer time.
*/
if (*delta > data->progress.t_redirect) {
return;
}
else {
break;
}
case TIMER_POSTRANSFER:
/* this is the normal end-of-transfer thing */
break;