]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
conn: eliminate `conn->now`
authorStefan Eissing <stefan@eissing.org>
Sat, 22 Mar 2025 10:22:22 +0000 (11:22 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Mon, 24 Mar 2025 08:57:38 +0000 (09:57 +0100)
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
lib/url.c
lib/urldata.h

index 5f4d42da40627ccb2e3fd02bc9e697c7ce7c2957..f90b40d3caab63663d6de5e80a92ed99795f2b0b 100644 (file)
 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);
   }
index 06f198ac33883938aec4da50e3980a96fe2c1fc5..cc0f6d372b3aa1783ae915b8686ebcdb48d13998 100644 (file)
--- 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);
index 0988b91fa7cab2240171553a1963c772448e0266..e4487ba6576d57b6b038cef1bbdd81a4365b1116 100644 (file)
@@ -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