summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2021-01-14 14:24:07 +0100
committerDaniel Stenberg <daniel@haxx.se>2021-01-14 23:16:39 +0100
commitb68dc34af341805aeb7b371541a2b4074da76217 (patch)
tree3c42641fb8e4fdec0d5cbf4cca9da92f639b2375
parentec8dcd7b3303a9e2ec4f4150727c1f7321f64052 (diff)
downloadcurl-b68dc34af341805aeb7b371541a2b4074da76217.tar.gz
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
-rw-r--r--lib/multi.c32
1 files changed, 9 insertions, 23 deletions
diff --git a/lib/multi.c b/lib/multi.c
index a8fe1ed67..695a03bd0 100644
--- a/lib/multi.c
+++ b/lib/multi.c
@@ -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;
}