Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

http2: handful of http2 src cleanups #14825

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion node.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,6 @@
'src/node_contextify.cc',
'src/node_debug_options.cc',
'src/node_file.cc',
'src/node_http2_core.cc',
'src/node_http2.cc',
'src/node_http_parser.cc',
'src/node_main.cc',
Expand Down
34 changes: 28 additions & 6 deletions src/node_http2.cc
Original file line number Diff line number Diff line change
Expand Up @@ -74,35 +74,57 @@ struct http2_state {
double stream_state_buffer[IDX_STREAM_STATE_COUNT];
};

Freelist<nghttp2_data_chunk_t, FREELIST_MAX>
data_chunk_free_list;

Freelist<Nghttp2Stream, FREELIST_MAX> stream_free_list;

Freelist<nghttp2_header_list, FREELIST_MAX> header_free_list;

Freelist<nghttp2_data_chunks_t, FREELIST_MAX>
data_chunks_free_list;

Nghttp2Session::Callbacks Nghttp2Session::callback_struct_saved[2] = {
Callbacks(false),
Callbacks(true)};

Http2Options::Http2Options(Environment* env) {
nghttp2_option_new(&options_);

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

if (flags & (1 << IDX_OPTIONS_MAX_DEFLATE_DYNAMIC_TABLE_SIZE)) {
SetMaxDeflateDynamicTableSize(
nghttp2_option_set_max_deflate_dynamic_table_size(
options_,
buffer[IDX_OPTIONS_MAX_DEFLATE_DYNAMIC_TABLE_SIZE]);
}

if (flags & (1 << IDX_OPTIONS_MAX_RESERVED_REMOTE_STREAMS)) {
SetMaxReservedRemoteStreams(
nghttp2_option_set_max_reserved_remote_streams(
options_,
buffer[IDX_OPTIONS_MAX_RESERVED_REMOTE_STREAMS]);
}

if (flags & (1 << IDX_OPTIONS_MAX_SEND_HEADER_BLOCK_LENGTH)) {
SetMaxSendHeaderBlockLength(
nghttp2_option_set_max_send_header_block_length(
options_,
buffer[IDX_OPTIONS_MAX_SEND_HEADER_BLOCK_LENGTH]);
}

SetPeerMaxConcurrentStreams(100); // Recommended default
// Recommended default
nghttp2_option_set_peer_max_concurrent_streams(options_, 100);
if (flags & (1 << IDX_OPTIONS_PEER_MAX_CONCURRENT_STREAMS)) {
SetPeerMaxConcurrentStreams(
nghttp2_option_set_peer_max_concurrent_streams(
options_,
buffer[IDX_OPTIONS_PEER_MAX_CONCURRENT_STREAMS]);
}

if (flags & (1 << IDX_OPTIONS_PADDING_STRATEGY)) {
SetPaddingStrategy(buffer[IDX_OPTIONS_PADDING_STRATEGY]);
padding_strategy_type strategy =
static_cast<padding_strategy_type>(
buffer[IDX_OPTIONS_PADDING_STRATEGY]);
SetPaddingStrategy(strategy);
}
}

Expand Down
20 changes: 2 additions & 18 deletions src/node_http2.h
Original file line number Diff line number Diff line change
Expand Up @@ -273,31 +273,15 @@ class Http2Options {
nghttp2_option_del(options_);
}

nghttp2_option* operator*() {
nghttp2_option* operator*() const {
return options_;
}

void SetPaddingStrategy(uint32_t val) {
void SetPaddingStrategy(padding_strategy_type val) {
CHECK_LE(val, PADDING_STRATEGY_CALLBACK);
padding_strategy_ = static_cast<padding_strategy_type>(val);
}

void SetMaxDeflateDynamicTableSize(size_t val) {
nghttp2_option_set_max_deflate_dynamic_table_size(options_, val);
}

void SetMaxReservedRemoteStreams(uint32_t val) {
nghttp2_option_set_max_reserved_remote_streams(options_, val);
}

void SetMaxSendHeaderBlockLength(size_t val) {
nghttp2_option_set_max_send_header_block_length(options_, val);
}

void SetPeerMaxConcurrentStreams(uint32_t val) {
nghttp2_option_set_peer_max_concurrent_streams(options_, val);
}

padding_strategy_type GetPaddingStrategy() {
return padding_strategy_;
}
Expand Down
Loading