Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
fixes for @bnoordhuis
  • Loading branch information
indutny committed Nov 7, 2018
commit ffce9932641210509bcd3fafbd0368e0e5c4f946
2 changes: 1 addition & 1 deletion configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -1106,7 +1106,7 @@ def configure_node(o):
o['variables']['node_target_type'] = 'executable'

o['variables']['node_experimental_http_parser'] = \
'true' if options.experimental_http_parser else 'false'
b(options.experimental_http_parser)

def configure_library(lib, output):
shared_lib = 'shared_' + lib
Expand Down
23 changes: 9 additions & 14 deletions src/node_http_parser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -153,11 +153,6 @@ class Parser : public AsyncWrap, public StreamListener {
: AsyncWrap(env, wrap, AsyncWrap::PROVIDER_HTTPPARSER),
current_buffer_len_(0),
current_buffer_data_(nullptr) {
#ifdef NODE_EXPERIMENTAL_HTTP
executing_ = 0;
pending_pause_ = false;
header_nread_ = 0;
#endif /* NODE_EXPERIMENTAL_HTTP */
Init(type);
}

Expand Down Expand Up @@ -530,7 +525,7 @@ class Parser : public AsyncWrap, public StreamListener {
CHECK_EQ(env, parser->env());

#ifdef NODE_EXPERIMENTAL_HTTP
if (parser->executing_) {
if (parser->execute_depth_) {
parser->pending_pause_ = should_pause;
return;
}
Expand Down Expand Up @@ -656,23 +651,23 @@ class Parser : public AsyncWrap, public StreamListener {

#ifdef NODE_EXPERIMENTAL_HTTP
// Do not allow re-entering `http_parser_execute()`
CHECK_EQ(executing_, 0);
CHECK_EQ(execute_depth_, 0);

executing_++;
execute_depth_++;
if (data == nullptr) {
err = llhttp_finish(&parser_);
} else {
err = llhttp_execute(&parser_, data, len);
Save();
}
executing_--;
execute_depth_--;

// Calculate bytes read and resume after Upgrade/CONNECT pause
size_t nread = len;
if (err != HPE_OK) {
nread = llhttp_get_error_pos(&parser_) - data;

/* This isn't a real pause, just a way to stop parsing early */
// This isn't a real pause, just a way to stop parsing early.
if (err == HPE_PAUSED_UPGRADE) {
err = HPE_OK;
llhttp_resume_after_upgrade(&parser_);
Expand Down Expand Up @@ -806,7 +801,7 @@ class Parser : public AsyncWrap, public StreamListener {

int MaybePause() {
#ifdef NODE_EXPERIMENTAL_HTTP
CHECK_NE(executing_, 0);
CHECK_NE(execute_depth_, 0);

if (!pending_pause_) {
return 0;
Expand All @@ -833,9 +828,9 @@ class Parser : public AsyncWrap, public StreamListener {
size_t current_buffer_len_;
char* current_buffer_data_;
#ifdef NODE_EXPERIMENTAL_HTTP
unsigned int executing_;
bool pending_pause_;
uint64_t header_nread_;
unsigned int execute_depth_ = 0;
bool pending_pause_ = false;
uint64_t header_nread_ = 0;
#endif /* NODE_EXPERIMENTAL_HTTP */

// These are helper functions for filling `http_parser_settings`, which turn
Expand Down