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 14:25:16 +0100
commitf281c617055bc1a81ab27d838cb36a7765927dc1 (patch)
tree682f93926449aa87b6950823b3e4325708dfca40
parent8f32ead8bf38ba7cb86c98f16db7c0e28a5c07c8 (diff)
downloadcurl-bagder/pretransfer-state.tar.gz
multi: set the PRETRANSFER time-stamp when we switch to PERFORMbagder/pretransfer-state
... 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.
-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;
}