]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
connect: shutdown timer fix
authorStefan Eissing <stefan@eissing.org>
Tue, 22 Apr 2025 13:23:36 +0000 (15:23 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Tue, 22 Apr 2025 13:52:17 +0000 (15:52 +0200)
Fix a bug in timeout handling for connection shutdowns that led to
default timeout of 2 seconds not being in effect.

Only set the shutdown timeout expiry when operating on a non-admin
transfers. Admin handles are only temproarily tied to a connection.

Fixes #17130
Reported-by: Rasmus Melchior Jacobsen
Closes #17135

lib/connect.c

index 18a592a7a76b0032211cbe7232061ff8c9a78dcf..a257b656a8695273fa3217be9c7c50b43eb3643e 100644 (file)
@@ -171,11 +171,12 @@ void Curl_shutdown_start(struct Curl_easy *data, int sockindex,
     nowp = &now;
   }
   data->conn->shutdown.start[sockindex] = *nowp;
-  data->conn->shutdown.timeout_ms = (timeout_ms >= 0) ?
+  data->conn->shutdown.timeout_ms = (timeout_ms > 0) ?
     (unsigned int)timeout_ms :
     ((data->set.shutdowntimeout > 0) ?
      data->set.shutdowntimeout : DEFAULT_SHUTDOWN_TIMEOUT_MS);
-  if(data->conn->shutdown.timeout_ms)
+  /* Set a timer, unless we operate on the admin handle */
+  if(data->mid && data->conn->shutdown.timeout_ms)
     Curl_expire_ex(data, nowp, data->conn->shutdown.timeout_ms,
                    EXPIRE_SHUTDOWN);
 }