]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
easy: during upkeep, attach Curl_easy to connections in the cache
authorJosie Huddleston <Josie.Huddleston@metaswitch.com>
Tue, 13 Jul 2021 12:23:26 +0000 (13:23 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Sat, 17 Jul 2021 21:43:55 +0000 (23:43 +0200)
During the protocol-specific parts of connection upkeep, some code
assumes that the data->conn pointer already is set correctly.  However,
there's currently no guarantee of that in the code.

This fix temporarily attaches each connection to the Curl_easy object
before performing the protocol-specific connection check on it, in a
similar manner to the connection checking in extract_if_dead().

Fixes #7386
Closes #7387
Reported-by: Josie Huddleston
lib/easy.c

index f682c28a727a12e560cea25b073c9dd52e0161e0..588b1fb47ecdcde8e0c0ac3306346ea9279d883e 100644 (file)
@@ -1213,9 +1213,16 @@ static int conn_upkeep(struct Curl_easy *data,
   /* Param is unused. */
   (void)param;
 
-  if(conn->handler->connection_check)
+  if(conn->handler->connection_check) {
+    /* briefly attach the connection to this transfer for the purpose of
+       checking it */
+    Curl_attach_connnection(data, conn);
+
     /* Do a protocol-specific keepalive check on the connection. */
     conn->handler->connection_check(data, conn, CONNCHECK_KEEPALIVE);
+    /* detach the connection again */
+    Curl_detach_connnection(data);
+  }
 
   return 0; /* continue iteration */
 }