Skip to content

Commit 80fe40a

Browse files
jasnellMylesBorins
authored andcommitted
http2: handful of http/2 src cleanups
* inline more stuff. remove a node_http2_core.cc * clean up debug messages * simplify options code, and cleanup PR-URL: #14825 Reviewed-By: Anna Henningsen <[email protected]>
1 parent b0f4539 commit 80fe40a

6 files changed

+433
-440
lines changed

node.gyp

-1
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,6 @@
185185
'src/node_contextify.cc',
186186
'src/node_debug_options.cc',
187187
'src/node_file.cc',
188-
'src/node_http2_core.cc',
189188
'src/node_http2.cc',
190189
'src/node_http_parser.cc',
191190
'src/node_main.cc',

src/node_http2.cc

+28-6
Original file line numberDiff line numberDiff line change
@@ -74,35 +74,57 @@ struct http2_state {
7474
double stream_state_buffer[IDX_STREAM_STATE_COUNT];
7575
};
7676

77+
Freelist<nghttp2_data_chunk_t, FREELIST_MAX>
78+
data_chunk_free_list;
79+
80+
Freelist<Nghttp2Stream, FREELIST_MAX> stream_free_list;
81+
82+
Freelist<nghttp2_header_list, FREELIST_MAX> header_free_list;
83+
84+
Freelist<nghttp2_data_chunks_t, FREELIST_MAX>
85+
data_chunks_free_list;
86+
87+
Nghttp2Session::Callbacks Nghttp2Session::callback_struct_saved[2] = {
88+
Callbacks(false),
89+
Callbacks(true)};
90+
7791
Http2Options::Http2Options(Environment* env) {
7892
nghttp2_option_new(&options_);
7993

8094
uint32_t* buffer = env->http2_state_buffer()->options_buffer;
8195
uint32_t flags = buffer[IDX_OPTIONS_FLAGS];
8296

8397
if (flags & (1 << IDX_OPTIONS_MAX_DEFLATE_DYNAMIC_TABLE_SIZE)) {
84-
SetMaxDeflateDynamicTableSize(
98+
nghttp2_option_set_max_deflate_dynamic_table_size(
99+
options_,
85100
buffer[IDX_OPTIONS_MAX_DEFLATE_DYNAMIC_TABLE_SIZE]);
86101
}
87102

88103
if (flags & (1 << IDX_OPTIONS_MAX_RESERVED_REMOTE_STREAMS)) {
89-
SetMaxReservedRemoteStreams(
104+
nghttp2_option_set_max_reserved_remote_streams(
105+
options_,
90106
buffer[IDX_OPTIONS_MAX_RESERVED_REMOTE_STREAMS]);
91107
}
92108

93109
if (flags & (1 << IDX_OPTIONS_MAX_SEND_HEADER_BLOCK_LENGTH)) {
94-
SetMaxSendHeaderBlockLength(
110+
nghttp2_option_set_max_send_header_block_length(
111+
options_,
95112
buffer[IDX_OPTIONS_MAX_SEND_HEADER_BLOCK_LENGTH]);
96113
}
97114

98-
SetPeerMaxConcurrentStreams(100); // Recommended default
115+
// Recommended default
116+
nghttp2_option_set_peer_max_concurrent_streams(options_, 100);
99117
if (flags & (1 << IDX_OPTIONS_PEER_MAX_CONCURRENT_STREAMS)) {
100-
SetPeerMaxConcurrentStreams(
118+
nghttp2_option_set_peer_max_concurrent_streams(
119+
options_,
101120
buffer[IDX_OPTIONS_PEER_MAX_CONCURRENT_STREAMS]);
102121
}
103122

104123
if (flags & (1 << IDX_OPTIONS_PADDING_STRATEGY)) {
105-
SetPaddingStrategy(buffer[IDX_OPTIONS_PADDING_STRATEGY]);
124+
padding_strategy_type strategy =
125+
static_cast<padding_strategy_type>(
126+
buffer[IDX_OPTIONS_PADDING_STRATEGY]);
127+
SetPaddingStrategy(strategy);
106128
}
107129
}
108130

src/node_http2.h

+2-18
Original file line numberDiff line numberDiff line change
@@ -273,31 +273,15 @@ class Http2Options {
273273
nghttp2_option_del(options_);
274274
}
275275

276-
nghttp2_option* operator*() {
276+
nghttp2_option* operator*() const {
277277
return options_;
278278
}
279279

280-
void SetPaddingStrategy(uint32_t val) {
280+
void SetPaddingStrategy(padding_strategy_type val) {
281281
CHECK_LE(val, PADDING_STRATEGY_CALLBACK);
282282
padding_strategy_ = static_cast<padding_strategy_type>(val);
283283
}
284284

285-
void SetMaxDeflateDynamicTableSize(size_t val) {
286-
nghttp2_option_set_max_deflate_dynamic_table_size(options_, val);
287-
}
288-
289-
void SetMaxReservedRemoteStreams(uint32_t val) {
290-
nghttp2_option_set_max_reserved_remote_streams(options_, val);
291-
}
292-
293-
void SetMaxSendHeaderBlockLength(size_t val) {
294-
nghttp2_option_set_max_send_header_block_length(options_, val);
295-
}
296-
297-
void SetPeerMaxConcurrentStreams(uint32_t val) {
298-
nghttp2_option_set_peer_max_concurrent_streams(options_, val);
299-
}
300-
301285
padding_strategy_type GetPaddingStrategy() {
302286
return padding_strategy_;
303287
}

0 commit comments

Comments
 (0)