1
0
mirror of https://github.com/moparisthebest/curl synced 2024-08-13 17:03:50 -04:00

multi: set the PRETRANSFER time-stamp when we switch to PERFORM

... instead of at end of the DO state. This makes the timer more
accurate for the protocols that use the DOING state (such as FTP), and
simplifies how the function (now called init_perform) is called.

The timer will then include the entire procedure up to PERFORM -
including all instructions for getting the transfer started.

Closes #6454
This commit is contained in:
Daniel Stenberg 2021-01-14 14:24:07 +01:00
parent ec8dcd7b33
commit b68dc34af3
No known key found for this signature in database
GPG Key ID: 5CC908FDB71E12C2

View File

@ -105,6 +105,13 @@ static const char * const statename[]={
/* function pointer called once when switching TO a state */
typedef void (*init_multistate_func)(struct Curl_easy *data);
/* called when the PERFORM state starts */
static void init_perform(struct Curl_easy *data)
{
data->req.chunk = FALSE;
Curl_pgrsTime(data, TIMER_PRETRANSFER);
}
static void init_completed(struct Curl_easy *data)
{
/* this is a completed transfer */
@ -136,7 +143,7 @@ static void mstate(struct Curl_easy *data, CURLMstate state
NULL, /* DOING */
NULL, /* DO_MORE */
NULL, /* DO_DONE */
NULL, /* PERFORM */
init_perform, /* PERFORM */
NULL, /* TOOFAST */
NULL, /* DONE */
init_completed, /* COMPLETED */
@ -1383,18 +1390,6 @@ CURLMcode Curl_multi_add_perform(struct Curl_multi *multi,
return rc;
}
/*
* do_complete is called when the DO actions are complete.
*
* We init chunking and trailer bits to their default values here immediately
* before receiving any header data for the current request.
*/
static void do_complete(struct connectdata *conn)
{
conn->data->req.chunk = FALSE;
Curl_pgrsTime(conn->data, TIMER_PRETRANSFER);
}
static CURLcode multi_do(struct Curl_easy *data, bool *done)
{
CURLcode result = CURLE_OK;
@ -1404,14 +1399,9 @@ static CURLcode multi_do(struct Curl_easy *data, bool *done)
DEBUGASSERT(conn->handler);
DEBUGASSERT(conn->data == data);
if(conn->handler->do_it) {
if(conn->handler->do_it)
/* generic protocol-specific function pointer set in curl_connect() */
result = conn->handler->do_it(conn, done);
if(!result && *done)
/* do_complete must be called after the protocol-specific DO function */
do_complete(conn);
}
return result;
}
@ -1433,10 +1423,6 @@ static CURLcode multi_do_more(struct connectdata *conn, int *complete)
if(conn->handler->do_more)
result = conn->handler->do_more(conn, complete);
if(!result && (*complete == 1))
/* do_complete must be called after the protocol-specific DO function */
do_complete(conn);
return result;
}