]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
urldata: store tcp_keepidle and tcp_keepintvl as ints
authorDaniel Stenberg <daniel@haxx.se>
Tue, 31 May 2022 11:42:35 +0000 (13:42 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Wed, 1 Jun 2022 06:12:09 +0000 (08:12 +0200)
They can't be set larger than INT_MAX in the setsocket API calls.

Also document the max values in their respective man pages.

Closes #8940

docs/libcurl/opts/CURLOPT_TCP_KEEPIDLE.3
docs/libcurl/opts/CURLOPT_TCP_KEEPINTVL.3
lib/setopt.c
lib/urldata.h

index 020d20ea02cebc24893e41968912474072c0baf6..7d803faef498fcf5c076663178ac6e9e24ef86f2 100644 (file)
@@ -5,7 +5,7 @@
 .\" *                            | (__| |_| |  _ <| |___
 .\" *                             \___|\___/|_| \_\_____|
 .\" *
-.\" * Copyright (C) 1998 - 2021, Daniel Stenberg, <daniel@haxx.se>, et al.
+.\" * Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al.
 .\" *
 .\" * This software is licensed as described in the file COPYING, which
 .\" * you should have received as part of this distribution. The terms
@@ -33,6 +33,9 @@ CURLcode curl_easy_setopt(CURL *handle, CURLOPT_TCP_KEEPIDLE, long delay);
 Pass a long. Sets the \fIdelay\fP, in seconds, that the operating system will
 wait while the connection is idle before sending keepalive probes. Not all
 operating systems support this option.
+
+The maximum value this accepts is 2147483648. Any larger value will be capped
+to this amount.
 .SH DEFAULT
 60
 .SH PROTOCOLS
index a157e7fbeae4c2f029f2c1ab8836860c5b9bceda..4e5e94c363880a37dca40afc6c107e5d8341111c 100644 (file)
@@ -5,7 +5,7 @@
 .\" *                            | (__| |_| |  _ <| |___
 .\" *                             \___|\___/|_| \_\_____|
 .\" *
-.\" * Copyright (C) 1998 - 2021, Daniel Stenberg, <daniel@haxx.se>, et al.
+.\" * Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al.
 .\" *
 .\" * This software is licensed as described in the file COPYING, which
 .\" * you should have received as part of this distribution. The terms
@@ -33,6 +33,9 @@ CURLcode curl_easy_setopt(CURL *handle, CURLOPT_TCP_KEEPINTVL, long interval);
 Pass a long. Sets the interval, in seconds, that the operating system will
 wait between sending keepalive probes. Not all operating systems support this
 option. (Added in 7.25.0)
+
+The maximum value this accepts is 2147483648. Any larger value will be capped
+to this amount.
 .SH DEFAULT
 60
 .SH PROTOCOLS
index fa3c4766f39ba471329edd960f6e1b968479476b..221ee4b409555c0d3aa2457c0186e147c49839d2 100644 (file)
@@ -2818,13 +2818,17 @@ CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option, va_list param)
     arg = va_arg(param, long);
     if(arg < 0)
       return CURLE_BAD_FUNCTION_ARGUMENT;
-    data->set.tcp_keepidle = arg;
+    else if(arg > INT_MAX)
+      arg = INT_MAX;
+    data->set.tcp_keepidle = (int)arg;
     break;
   case CURLOPT_TCP_KEEPINTVL:
     arg = va_arg(param, long);
     if(arg < 0)
       return CURLE_BAD_FUNCTION_ARGUMENT;
-    data->set.tcp_keepintvl = arg;
+    else if(arg > INT_MAX)
+      arg = INT_MAX;
+    data->set.tcp_keepintvl = (int)arg;
     break;
   case CURLOPT_TCP_FASTOPEN:
 #if defined(CONNECT_DATA_IDEMPOTENT) || defined(MSG_FASTOPEN) || \
index 63026063a5ff38d38ea1541befe4545f0f532f01..3b70439718935a9c99cdfac37d2d2e9e86e6f222 100644 (file)
@@ -1770,8 +1770,8 @@ struct UserDefined {
   long gssapi_delegation; /* GSS-API credential delegation, see the
                              documentation of CURLOPT_GSSAPI_DELEGATION */
 
-  long tcp_keepidle;     /* seconds in idle before sending keepalive probe */
-  long tcp_keepintvl;    /* seconds between TCP keepalive probes */
+  int tcp_keepidle;     /* seconds in idle before sending keepalive probe */
+  int tcp_keepintvl;    /* seconds between TCP keepalive probes */
 
   size_t maxconnects;    /* Max idle connections in the connection cache */