From f68eae250badec34d5f070788d3fbd313ae46af5 Mon Sep 17 00:00:00 2001 From: Stefan Eissing Date: Sat, 22 Mar 2025 11:22:22 +0100 Subject: [PATCH] conn: eliminate `conn->now` it was only used in pingpong.c to check if the overall transfer has timed out and we do that with `Curl_timeleft()` in all other places. Closes #16793 --- lib/pingpong.c | 11 ++++------- lib/url.c | 3 --- lib/urldata.h | 1 - 3 files changed, 4 insertions(+), 11 deletions(-) diff --git a/lib/pingpong.c b/lib/pingpong.c index 5f4d42da40..f90b40d3ca 100644 --- a/lib/pingpong.c +++ b/lib/pingpong.c @@ -51,10 +51,10 @@ timediff_t Curl_pp_state_timeout(struct Curl_easy *data, struct pingpong *pp, bool disconnecting) { - struct connectdata *conn = data->conn; timediff_t timeout_ms; /* in milliseconds */ timediff_t response_time = (data->set.server_response_timeout) ? data->set.server_response_timeout : pp->response_time; + struct curltime now = Curl_now(); /* if CURLOPT_SERVER_RESPONSE_TIMEOUT is set, use that to determine remaining time, or use pp->response because SERVER_RESPONSE_TIMEOUT is @@ -63,14 +63,11 @@ timediff_t Curl_pp_state_timeout(struct Curl_easy *data, /* Without a requested timeout, we only wait 'response_time' seconds for the full response to arrive before we bail out */ - timeout_ms = response_time - - Curl_timediff(Curl_now(), pp->response); /* spent time */ + timeout_ms = response_time - Curl_timediff(now, pp->response); if(data->set.timeout && !disconnecting) { - /* if timeout is requested, find out how much remaining time we have */ - timediff_t timeout2_ms = data->set.timeout - /* timeout time */ - Curl_timediff(Curl_now(), conn->now); /* spent time */ - + /* if timeout is requested, find out how much overall remains */ + timediff_t timeout2_ms = Curl_timeleft(data, &now, FALSE); /* pick the lowest number */ timeout_ms = CURLMIN(timeout_ms, timeout2_ms); } diff --git a/lib/url.c b/lib/url.c index 06f198ac33..cc0f6d372b 100644 --- a/lib/url.c +++ b/lib/url.c @@ -3781,9 +3781,6 @@ CURLcode Curl_setup_conn(struct Curl_easy *data, return result; } - /* set start time here for timeout purposes in the connect procedure, it - is later set again for the progress meter purpose */ - conn->now = Curl_now(); if(!conn->bits.reuse) result = Curl_conn_setup(data, conn, FIRSTSOCKET, conn->dns_entry, CURL_CF_SSL_DEFAULT); diff --git a/lib/urldata.h b/lib/urldata.h index 0988b91fa7..e4487ba657 100644 --- a/lib/urldata.h +++ b/lib/urldata.h @@ -803,7 +803,6 @@ struct connectdata { char *options; /* options string, allocated */ char *sasl_authzid; /* authorization identity string, allocated */ char *oauth_bearer; /* OAUTH2 bearer, allocated */ - struct curltime now; /* "current" time */ struct curltime created; /* creation time */ struct curltime lastused; /* when returned to the connection poolas idle */ curl_socket_t sock[2]; /* two sockets, the second is used for the data -- 2.47.2