Skip to content

Commit

Permalink
http2: handful of http/2 src cleanups
Browse files Browse the repository at this point in the history
* 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 <anna@addaleax.net>
  • Loading branch information
jasnell authored and MylesBorins committed Sep 12, 2017
1 parent b0f4539 commit 80fe40a
Show file tree
Hide file tree
Showing 6 changed files with 433 additions and 440 deletions.
1 change: 0 additions & 1 deletion node.gyp
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
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
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

0 comments on commit 80fe40a

Please sign in to comment.