]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
CURLOPT_MAXLIFETIME_CONN: make default 24 hours
authorDaniel Stenberg <daniel@haxx.se>
Thu, 11 Sep 2025 15:50:59 +0000 (17:50 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Thu, 11 Sep 2025 17:46:41 +0000 (19:46 +0200)
Set a default value to only reuse existing connections if less than 24
hours old. This makes the TLS certificate check get redone for the new
connection. An application can still set it to zero.

Closes #18527

docs/libcurl/opts/CURLOPT_MAXLIFETIME_CONN.md
lib/url.c
lib/urldata.h

index b29e61a2c3e5cb4f9ab3fec622a9eaaaedf6862e..8c1fbf82f86b84b7e367ef0915d077908161b333 100644 (file)
@@ -35,16 +35,18 @@ connection to have to be considered for reuse for this request.
 
 libcurl features a connection cache that holds previously used connections.
 When a new request is to be done, libcurl considers any connection that
-matches for reuse. The CURLOPT_MAXLIFETIME_CONN(3) limit prevents
-libcurl from trying too old connections for reuse. This can be used for
-client-side load balancing. If a connection is found in the cache that is
-older than this set *maxlifetime*, it is instead marked for closure.
+matches for reuse. The CURLOPT_MAXLIFETIME_CONN(3) limit prevents libcurl from
+trying too old connections for reuse. This can be used for client-side load
+balancing. If a connection is found in the cache that is older than this set
+*maxlifetime*, it is instead marked for closure.
 
-If set to 0, this behavior is disabled: all connections are eligible for reuse.
+If set to 0, this behavior is disabled: all connections are eligible for
+reuse.
 
 # DEFAULT
 
-0 seconds (i.e., disabled)
+24 hours (since 8.17.0). Before that, the default was 0 seconds (i.e.,
+disabled)
 
 # %PROTOCOLS%
 
index 45d44bac738f6593c92098ba8681e9b11de103f8..283da6d68b5045cdde8ca13c3222069f37d2d503 100644 (file)
--- a/lib/url.c
+++ b/lib/url.c
@@ -488,7 +488,7 @@ CURLcode Curl_init_userdefined(struct Curl_easy *data)
   set->upkeep_interval_ms = CURL_UPKEEP_INTERVAL_DEFAULT;
   set->maxconnects = DEFAULT_CONNCACHE_SIZE; /* for easy handles */
   set->conn_max_idle_ms = 118 * 1000;
-  set->conn_max_age_ms = 0;
+  set->conn_max_age_ms = 24 * 3600 * 1000;
   set->http09_allowed = FALSE;
   set->httpwant = CURL_HTTP_VERSION_NONE
     ;
index cf181af641fd0c391396315c0e4b7c5563748db5..a0ee614da83862d059952d38d4ef21425d6a1648 100644 (file)
@@ -1390,9 +1390,9 @@ struct UserDefined {
   void *progress_client; /* pointer to pass to the progress callback */
   void *ioctl_client;   /* pointer to pass to the ioctl callback */
   timediff_t conn_max_idle_ms; /* max idle time to allow a connection that
-                           is to be reused */
+                                  is to be reused */
   timediff_t conn_max_age_ms; /* max time since creation to allow a
-                            connection that is to be reused */
+                                 connection that is to be reused */
   curl_off_t filesize;  /* size of file to upload, -1 means unknown */
   long low_speed_limit; /* bytes/second */
   long low_speed_time;  /* number of seconds */