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

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