mirror of
https://github.com/nodejs/node.git
synced 2025-08-15 13:48:44 +02:00
http2: expose nghttp2_option_set_stream_reset_rate_limit as an option
PR-URL: https://github.com/nodejs/node/pull/54875 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Richard Lau <rlau@redhat.com>
This commit is contained in:
parent
0f02810fc9
commit
6c6562ce8b
5 changed files with 39 additions and 2 deletions
|
@ -2766,6 +2766,10 @@ Throws `ERR_INVALID_ARG_TYPE` for invalid `settings` argument.
|
||||||
<!-- YAML
|
<!-- YAML
|
||||||
added: v8.4.0
|
added: v8.4.0
|
||||||
changes:
|
changes:
|
||||||
|
- version:
|
||||||
|
- REPLACEME
|
||||||
|
pr-url: https://github.com/nodejs/node/pull/54875
|
||||||
|
description: Added `streamResetBurst` and `streamResetRate`.
|
||||||
- version:
|
- version:
|
||||||
- v15.10.0
|
- v15.10.0
|
||||||
- v14.16.0
|
- v14.16.0
|
||||||
|
@ -2868,6 +2872,9 @@ changes:
|
||||||
**Default:** `100`.
|
**Default:** `100`.
|
||||||
* `settings` {HTTP/2 Settings Object} The initial settings to send to the
|
* `settings` {HTTP/2 Settings Object} The initial settings to send to the
|
||||||
remote peer upon connection.
|
remote peer upon connection.
|
||||||
|
* `streamResetBurst` {number} and `streamResetRate` {number} Sets the rate
|
||||||
|
limit for the incoming stream reset (RST\_STREAM frame). Both settings must
|
||||||
|
be set to have any effect, and default to 1000 and 33 respectively.
|
||||||
* `remoteCustomSettings` {Array} The array of integer values determines the
|
* `remoteCustomSettings` {Array} The array of integer values determines the
|
||||||
settings types, which are included in the `CustomSettings`-property of
|
settings types, which are included in the `CustomSettings`-property of
|
||||||
the received remoteSettings. Please see the `CustomSettings`-property of
|
the received remoteSettings. Please see the `CustomSettings`-property of
|
||||||
|
|
|
@ -216,7 +216,9 @@ const IDX_OPTIONS_MAX_OUTSTANDING_PINGS = 6;
|
||||||
const IDX_OPTIONS_MAX_OUTSTANDING_SETTINGS = 7;
|
const IDX_OPTIONS_MAX_OUTSTANDING_SETTINGS = 7;
|
||||||
const IDX_OPTIONS_MAX_SESSION_MEMORY = 8;
|
const IDX_OPTIONS_MAX_SESSION_MEMORY = 8;
|
||||||
const IDX_OPTIONS_MAX_SETTINGS = 9;
|
const IDX_OPTIONS_MAX_SETTINGS = 9;
|
||||||
const IDX_OPTIONS_FLAGS = 10;
|
const IDX_OPTIONS_STREAM_RESET_RATE = 10;
|
||||||
|
const IDX_OPTIONS_STREAM_RESET_BURST = 11;
|
||||||
|
const IDX_OPTIONS_FLAGS = 12;
|
||||||
|
|
||||||
function updateOptionsBuffer(options) {
|
function updateOptionsBuffer(options) {
|
||||||
let flags = 0;
|
let flags = 0;
|
||||||
|
@ -270,6 +272,16 @@ function updateOptionsBuffer(options) {
|
||||||
optionsBuffer[IDX_OPTIONS_MAX_SETTINGS] =
|
optionsBuffer[IDX_OPTIONS_MAX_SETTINGS] =
|
||||||
MathMax(1, options.maxSettings);
|
MathMax(1, options.maxSettings);
|
||||||
}
|
}
|
||||||
|
if (typeof options.streamResetRate === 'number') {
|
||||||
|
flags |= (1 << IDX_OPTIONS_STREAM_RESET_RATE);
|
||||||
|
optionsBuffer[IDX_OPTIONS_STREAM_RESET_RATE] =
|
||||||
|
MathMax(1, options.streamResetRate);
|
||||||
|
}
|
||||||
|
if (typeof options.streamResetBurst === 'number') {
|
||||||
|
flags |= (1 << IDX_OPTIONS_STREAM_RESET_BURST);
|
||||||
|
optionsBuffer[IDX_OPTIONS_STREAM_RESET_BURST] =
|
||||||
|
MathMax(1, options.streamResetBurst);
|
||||||
|
}
|
||||||
optionsBuffer[IDX_OPTIONS_FLAGS] = flags;
|
optionsBuffer[IDX_OPTIONS_FLAGS] = flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -208,6 +208,14 @@ Http2Options::Http2Options(Http2State* http2_state, SessionType type) {
|
||||||
option,
|
option,
|
||||||
static_cast<size_t>(buffer[IDX_OPTIONS_MAX_SETTINGS]));
|
static_cast<size_t>(buffer[IDX_OPTIONS_MAX_SETTINGS]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((flags & (1 << IDX_OPTIONS_STREAM_RESET_BURST)) &&
|
||||||
|
(flags & (1 << IDX_OPTIONS_STREAM_RESET_RATE))) {
|
||||||
|
nghttp2_option_set_stream_reset_rate_limit(
|
||||||
|
option,
|
||||||
|
static_cast<uint64_t>(buffer[IDX_OPTIONS_STREAM_RESET_BURST]),
|
||||||
|
static_cast<uint64_t>(buffer[IDX_OPTIONS_STREAM_RESET_RATE]));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#define GRABSETTING(entries, count, name) \
|
#define GRABSETTING(entries, count, name) \
|
||||||
|
|
|
@ -58,6 +58,8 @@ namespace http2 {
|
||||||
IDX_OPTIONS_MAX_OUTSTANDING_SETTINGS,
|
IDX_OPTIONS_MAX_OUTSTANDING_SETTINGS,
|
||||||
IDX_OPTIONS_MAX_SESSION_MEMORY,
|
IDX_OPTIONS_MAX_SESSION_MEMORY,
|
||||||
IDX_OPTIONS_MAX_SETTINGS,
|
IDX_OPTIONS_MAX_SETTINGS,
|
||||||
|
IDX_OPTIONS_STREAM_RESET_RATE,
|
||||||
|
IDX_OPTIONS_STREAM_RESET_BURST,
|
||||||
IDX_OPTIONS_FLAGS
|
IDX_OPTIONS_FLAGS
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,9 @@ const IDX_OPTIONS_MAX_OUTSTANDING_PINGS = 6;
|
||||||
const IDX_OPTIONS_MAX_OUTSTANDING_SETTINGS = 7;
|
const IDX_OPTIONS_MAX_OUTSTANDING_SETTINGS = 7;
|
||||||
const IDX_OPTIONS_MAX_SESSION_MEMORY = 8;
|
const IDX_OPTIONS_MAX_SESSION_MEMORY = 8;
|
||||||
const IDX_OPTIONS_MAX_SETTINGS = 9;
|
const IDX_OPTIONS_MAX_SETTINGS = 9;
|
||||||
const IDX_OPTIONS_FLAGS = 10;
|
const IDX_OPTIONS_STREAM_RESET_RATE = 10;
|
||||||
|
const IDX_OPTIONS_STREAM_RESET_BURST = 11;
|
||||||
|
const IDX_OPTIONS_FLAGS = 12;
|
||||||
|
|
||||||
{
|
{
|
||||||
updateOptionsBuffer({
|
updateOptionsBuffer({
|
||||||
|
@ -37,6 +39,8 @@ const IDX_OPTIONS_FLAGS = 10;
|
||||||
maxOutstandingSettings: 8,
|
maxOutstandingSettings: 8,
|
||||||
maxSessionMemory: 9,
|
maxSessionMemory: 9,
|
||||||
maxSettings: 10,
|
maxSettings: 10,
|
||||||
|
streamResetRate: 11,
|
||||||
|
streamResetBurst: 12,
|
||||||
});
|
});
|
||||||
|
|
||||||
strictEqual(optionsBuffer[IDX_OPTIONS_MAX_DEFLATE_DYNAMIC_TABLE_SIZE], 1);
|
strictEqual(optionsBuffer[IDX_OPTIONS_MAX_DEFLATE_DYNAMIC_TABLE_SIZE], 1);
|
||||||
|
@ -49,6 +53,8 @@ const IDX_OPTIONS_FLAGS = 10;
|
||||||
strictEqual(optionsBuffer[IDX_OPTIONS_MAX_OUTSTANDING_SETTINGS], 8);
|
strictEqual(optionsBuffer[IDX_OPTIONS_MAX_OUTSTANDING_SETTINGS], 8);
|
||||||
strictEqual(optionsBuffer[IDX_OPTIONS_MAX_SESSION_MEMORY], 9);
|
strictEqual(optionsBuffer[IDX_OPTIONS_MAX_SESSION_MEMORY], 9);
|
||||||
strictEqual(optionsBuffer[IDX_OPTIONS_MAX_SETTINGS], 10);
|
strictEqual(optionsBuffer[IDX_OPTIONS_MAX_SETTINGS], 10);
|
||||||
|
strictEqual(optionsBuffer[IDX_OPTIONS_STREAM_RESET_RATE], 11);
|
||||||
|
strictEqual(optionsBuffer[IDX_OPTIONS_STREAM_RESET_BURST], 12);
|
||||||
|
|
||||||
const flags = optionsBuffer[IDX_OPTIONS_FLAGS];
|
const flags = optionsBuffer[IDX_OPTIONS_FLAGS];
|
||||||
|
|
||||||
|
@ -61,6 +67,8 @@ const IDX_OPTIONS_FLAGS = 10;
|
||||||
ok(flags & (1 << IDX_OPTIONS_MAX_OUTSTANDING_PINGS));
|
ok(flags & (1 << IDX_OPTIONS_MAX_OUTSTANDING_PINGS));
|
||||||
ok(flags & (1 << IDX_OPTIONS_MAX_OUTSTANDING_SETTINGS));
|
ok(flags & (1 << IDX_OPTIONS_MAX_OUTSTANDING_SETTINGS));
|
||||||
ok(flags & (1 << IDX_OPTIONS_MAX_SETTINGS));
|
ok(flags & (1 << IDX_OPTIONS_MAX_SETTINGS));
|
||||||
|
ok(flags & (1 << IDX_OPTIONS_STREAM_RESET_RATE));
|
||||||
|
ok(flags & (1 << IDX_OPTIONS_STREAM_RESET_BURST));
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue