urldata: store tcp_keepidle and tcp_keepintvl as ints

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
This commit is contained in:
Daniel Stenberg 2022-05-31 13:42:35 +02:00
parent 4651945822
commit 8b1ae28509
No known key found for this signature in database
GPG Key ID: 5CC908FDB71E12C2
4 changed files with 16 additions and 6 deletions

View 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

View 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

View 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) || \

View 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 */