CURLMOPT_MAX_CONCURRENT_STREAMS: new setopt

Closes #4410
This commit is contained in:
Kunal Ekawde 2019-09-24 08:56:11 -04:00 committed by Daniel Stenberg
parent f0f053fed0
commit c124e6b3c0
No known key found for this signature in database
GPG Key ID: 5CC908FDB71E12C2
10 changed files with 97 additions and 6 deletions

View File

@ -5,7 +5,7 @@
.\" * | (__| |_| | _ <| |___
.\" * \___|\___/|_| \_\_____|
.\" *
.\" * Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
.\" * Copyright (C) 1998 - 2019, 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
@ -67,6 +67,8 @@ See \fICURLMOPT_SOCKETDATA(3)\fP
See \fICURLMOPT_TIMERFUNCTION(3)\fP
.IP CURLMOPT_TIMERDATA
See \fICURLMOPT_TIMERDATA(3)\fP
.IP CURLMOPT_MAX_CONCURRENT_STREAMS
See \fICURLMOPT_MAX_CONCURRENT_STREAMS(3)\fP
.SH RETURNS
The standard CURLMcode for multi interface error codes. Note that it returns a
CURLM_UNKNOWN_OPTION if you try setting an option that this version of libcurl

View File

@ -0,0 +1,56 @@
.\" **************************************************************************
.\" * _ _ ____ _
.\" * Project ___| | | | _ \| |
.\" * / __| | | | |_) | |
.\" * | (__| |_| | _ <| |___
.\" * \___|\___/|_| \_\_____|
.\" *
.\" * Copyright (C) 1998 - 2019, 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
.\" * are also available at https://curl.haxx.se/docs/copyright.html.
.\" *
.\" * You may opt to use, copy, modify, merge, publish, distribute and/or sell
.\" * copies of the Software, and permit persons to whom the Software is
.\" * furnished to do so, under the terms of the COPYING file.
.\" *
.\" * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
.\" * KIND, either express or implied.
.\" *
.\" **************************************************************************
.\"
.TH CURLMOPT_MAX_CONCURRENT_STREAMS 3 "06 Nov 2019" "libcurl 7.67.0" "curl_multi_setopt options"
.SH NAME
CURLMOPT_MAX_CONCURRENT_STREAMS \- set max concurrent streams for http2
.SH SYNOPSIS
.nf
#include <curl/curl.h>
CURLMcode curl_multi_setopt(CURLM *handle, CURLMOPT_MAX_CONCURRENT_STREAMS,
long max);
.fi
.SH DESCRIPTION
Pass a long indicating the \fBmax\fP. The set number will be used as the
maximum number of concurrent streams for a connections that libcurl should
support on connections done using HTTP/2.
Valid values range from 1 to 2147483647 (2^31 - 1) and defaults to 100. The
value passed here would be honoured based on other system resources
properties.
.SH DEFAULT
100
.SH PROTOCOLS
All
.SH EXAMPLE
.nf
CURLM *m = curl_multi_init();
/* max concurrent streams 200 */
curl_multi_setopt(m, CURLMOPT_MAX_CONCURRENT_STREAMS, 200L);
.fi
.SH AVAILABILITY
Added in 7.67.0
.SH RETURN VALUE
Returns CURLM_OK if the option is supported, and CURLM_UNKNOWN_OPTION if not.
.SH "SEE ALSO"
.BR CURLOPT_MAXCONNECTS "(3), " CURLMOPT_MAXCONNECTS.3 "(3), "

View File

@ -68,6 +68,7 @@ man_MANS = \
CURLMOPT_CHUNK_LENGTH_PENALTY_SIZE.3 \
CURLMOPT_CONTENT_LENGTH_PENALTY_SIZE.3 \
CURLMOPT_MAXCONNECTS.3 \
CURLMOPT_MAX_CONCURRENT_STREAMS.3 \
CURLMOPT_MAX_HOST_CONNECTIONS.3 \
CURLMOPT_MAX_PIPELINE_LENGTH.3 \
CURLMOPT_MAX_TOTAL_CONNECTIONS.3 \
@ -97,7 +98,6 @@ man_MANS = \
CURLOPT_CHUNK_END_FUNCTION.3 \
CURLOPT_CLOSESOCKETDATA.3 \
CURLOPT_CLOSESOCKETFUNCTION.3 \
CURLOPT_UPKEEP_INTERVAL_MS.3 \
CURLOPT_CONNECTTIMEOUT.3 \
CURLOPT_CONNECTTIMEOUT_MS.3 \
CURLOPT_CONNECT_ONLY.3 \
@ -113,8 +113,8 @@ man_MANS = \
CURLOPT_COPYPOSTFIELDS.3 \
CURLOPT_CRLF.3 \
CURLOPT_CRLFILE.3 \
CURLOPT_CUSTOMREQUEST.3 \
CURLOPT_CURLU.3 \
CURLOPT_CUSTOMREQUEST.3 \
CURLOPT_DEBUGDATA.3 \
CURLOPT_DEBUGFUNCTION.3 \
CURLOPT_DEFAULT_PROTOCOL.3 \
@ -168,8 +168,6 @@ man_MANS = \
CURLOPT_HTTP_TRANSFER_DECODING.3 \
CURLOPT_HTTP_VERSION.3 \
CURLOPT_IGNORE_CONTENT_LENGTH.3 \
CURLOPT_TRAILERDATA.3 \
CURLOPT_TRAILERFUNCTION.3 \
CURLOPT_INFILESIZE.3 \
CURLOPT_INFILESIZE_LARGE.3 \
CURLOPT_INTERFACE.3 \
@ -332,10 +330,13 @@ man_MANS = \
CURLOPT_TLSAUTH_PASSWORD.3 \
CURLOPT_TLSAUTH_TYPE.3 \
CURLOPT_TLSAUTH_USERNAME.3 \
CURLOPT_TRAILERDATA.3 \
CURLOPT_TRAILERFUNCTION.3 \
CURLOPT_TRANSFERTEXT.3 \
CURLOPT_TRANSFER_ENCODING.3 \
CURLOPT_UNIX_SOCKET_PATH.3 \
CURLOPT_UNRESTRICTED_AUTH.3 \
CURLOPT_UPKEEP_INTERVAL_MS.3 \
CURLOPT_UPLOAD.3 \
CURLOPT_UPLOAD_BUFFERSIZE.3 \
CURLOPT_URL.3 \

View File

@ -319,6 +319,7 @@ CURLMOPT_MAXCONNECTS 7.16.3
CURLMOPT_MAX_HOST_CONNECTIONS 7.30.0
CURLMOPT_MAX_PIPELINE_LENGTH 7.30.0
CURLMOPT_MAX_TOTAL_CONNECTIONS 7.30.0
CURLMOPT_MAX_CONCURRENT_STREAMS 7.67.0
CURLMOPT_PIPELINING 7.16.0
CURLMOPT_PIPELINING_SERVER_BL 7.30.0
CURLMOPT_PIPELINING_SITE_BL 7.30.0

View File

@ -396,6 +396,9 @@ typedef enum {
/* This is the argument passed to the server push callback */
CINIT(PUSHDATA, OBJECTPOINT, 15),
/* maximum number of concurrent streams to support on a connection */
CINIT(MAX_CONCURRENT_STREAMS, LONG, 16),
CURLMOPT_LASTENTRY /* the last unused */
} CURLMoption;
@ -448,6 +451,9 @@ typedef int (*curl_push_callback)(CURL *parent,
struct curl_pushheaders *headers,
void *userp);
/* value for MAXIMUM CONCURRENT STREAMS upper limit */
#define INITIAL_MAX_CONCURRENT_STREAMS ((1U << 31) - 1)
#ifdef __cplusplus
} /* end of extern "C" */
#endif

View File

@ -1159,7 +1159,7 @@ static void populate_settings(struct connectdata *conn,
nghttp2_settings_entry *iv = httpc->local_settings;
iv[0].settings_id = NGHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS;
iv[0].value = 100;
iv[0].value = (uint32_t)Curl_multi_max_concurrent_streams(conn->data->multi);
iv[1].settings_id = NGHTTP2_SETTINGS_INITIAL_WINDOW_SIZE;
iv[1].value = HTTP2_HUGE_WINDOW_SIZE;

View File

@ -2772,6 +2772,16 @@ CURLMcode curl_multi_setopt(struct Curl_multi *multi,
break;
case CURLMOPT_PIPELINING_SERVER_BL:
break;
case CURLMOPT_MAX_CONCURRENT_STREAMS:
{
long streams = va_arg(param, long);
if(streams < 1)
streams = 100;
multi->max_concurrent_streams =
(streams > (long)INITIAL_MAX_CONCURRENT_STREAMS)?
(long)INITIAL_MAX_CONCURRENT_STREAMS : streams;
}
break;
default:
res = CURLM_UNKNOWN_OPTION;
break;
@ -3210,3 +3220,9 @@ void Curl_multi_dump(struct Curl_multi *multi)
}
}
#endif
size_t Curl_multi_max_concurrent_streams(struct Curl_multi *multi)
{
return multi ? ((size_t)multi->max_concurrent_streams ?
(size_t)multi->max_concurrent_streams : 100) : 0;
}

View File

@ -133,6 +133,7 @@ struct Curl_multi {
struct curltime timer_lastcall; /* the fixed time for the timeout for the
previous callback */
bool in_callback; /* true while executing a callback */
long max_concurrent_streams; /* max concurrent streams client to support */
};
#endif /* HEADER_CURL_MULTIHANDLE_H */

View File

@ -89,4 +89,10 @@ CURLMcode Curl_multi_add_perform(struct Curl_multi *multi,
struct Curl_easy *data,
struct connectdata *conn);
/* Return the value of the CURLMOPT_MAX_CONCURRENT_STREAMS option
* If not specified or 0, default would be 100
*/
size_t Curl_multi_max_concurrent_streams(struct Curl_multi *multi);
#endif /* HEADER_CURL_MULTIIF_H */

View File

@ -1841,6 +1841,8 @@
d c 20014
d CURLMOPT_PUSHDATA...
d c 10015
d CURLMOPT_MAX_CONCURRENT_STREAMS...
d c 10016
*
* Bitmask bits for CURLMOPT_PIPELING.
*