http2: expose nghttp2_option_set_stream_reset_rate_limit as an option · nodejs/node@914db60 · GitHub
Skip to content

Commit 914db60

Browse files
arcanistargos
authored andcommitted
http2: expose nghttp2_option_set_stream_reset_rate_limit as an option
PR-URL: #54875 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Richard Lau <rlau@redhat.com>
1 parent 781ffd8 commit 914db60

5 files changed

Lines changed: 39 additions & 2 deletions

File tree

doc/api/http2.md

Lines changed: 7 additions & 0 deletions

lib/internal/http2/util.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,9 @@ const IDX_OPTIONS_MAX_OUTSTANDING_PINGS = 6;
216216
const IDX_OPTIONS_MAX_OUTSTANDING_SETTINGS = 7;
217217
const IDX_OPTIONS_MAX_SESSION_MEMORY = 8;
218218
const IDX_OPTIONS_MAX_SETTINGS = 9;
219-
const IDX_OPTIONS_FLAGS = 10;
219+
const IDX_OPTIONS_STREAM_RESET_RATE = 10;
220+
const IDX_OPTIONS_STREAM_RESET_BURST = 11;
221+
const IDX_OPTIONS_FLAGS = 12;
220222

221223
function updateOptionsBuffer(options) {
222224
let flags = 0;
@@ -270,6 +272,16 @@ function updateOptionsBuffer(options) {
270272
optionsBuffer[IDX_OPTIONS_MAX_SETTINGS] =
271273
MathMax(1, options.maxSettings);
272274
}
275+
if (typeof options.streamResetRate === 'number') {
276+
flags |= (1 << IDX_OPTIONS_STREAM_RESET_RATE);
277+
optionsBuffer[IDX_OPTIONS_STREAM_RESET_RATE] =
278+
MathMax(1, options.streamResetRate);
279+
}
280+
if (typeof options.streamResetBurst === 'number') {
281+
flags |= (1 << IDX_OPTIONS_STREAM_RESET_BURST);
282+
optionsBuffer[IDX_OPTIONS_STREAM_RESET_BURST] =
283+
MathMax(1, options.streamResetBurst);
284+
}
273285
optionsBuffer[IDX_OPTIONS_FLAGS] = flags;
274286
}
275287

src/node_http2.cc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,14 @@ Http2Options::Http2Options(Http2State* http2_state, SessionType type) {
208208
option,
209209
static_cast<size_t>(buffer[IDX_OPTIONS_MAX_SETTINGS]));
210210
}
211+
212+
if ((flags & (1 << IDX_OPTIONS_STREAM_RESET_BURST)) &&
213+
(flags & (1 << IDX_OPTIONS_STREAM_RESET_RATE))) {
214+
nghttp2_option_set_stream_reset_rate_limit(
215+
option,
216+
static_cast<uint64_t>(buffer[IDX_OPTIONS_STREAM_RESET_BURST]),
217+
static_cast<uint64_t>(buffer[IDX_OPTIONS_STREAM_RESET_RATE]));
218+
}
211219
}
212220

213221
#define GRABSETTING(entries, count, name) \

src/node_http2_state.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ namespace http2 {
5858
IDX_OPTIONS_MAX_OUTSTANDING_SETTINGS,
5959
IDX_OPTIONS_MAX_SESSION_MEMORY,
6060
IDX_OPTIONS_MAX_SETTINGS,
61+
IDX_OPTIONS_STREAM_RESET_RATE,
62+
IDX_OPTIONS_STREAM_RESET_BURST,
6163
IDX_OPTIONS_FLAGS
6264
};
6365

test/parallel/test-http2-util-update-options-buffer.js

Lines changed: 9 additions & 1 deletion

0 commit comments

Comments
 (0)