Skip to content

Commit

Permalink
async_wrap,http: handle init/destroy lifecycle within HttpParser
Browse files Browse the repository at this point in the history
  • Loading branch information
omsmith committed Mar 22, 2016
1 parent 206d243 commit 64082db
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/node_http_parser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ struct StringPtr {
class Parser : public AsyncWrap {
public:
Parser(Environment* env, Local<Object> wrap, enum http_parser_type type)
: AsyncWrap(env, wrap, AsyncWrap::PROVIDER_HTTPPARSER),
: AsyncWrap(env, wrap, AsyncWrap::PROVIDER_HTTPPARSER, nullptr, false),
current_buffer_len_(0),
current_buffer_data_(nullptr) {
Wrap(object(), this);
Expand Down Expand Up @@ -457,6 +457,7 @@ class Parser : public AsyncWrap {
// Should always be called from the same context.
CHECK_EQ(env, parser->env());
parser->Init(type);
parser->InitAsyncWrap(env, args.This(), AsyncWrap::PROVIDER_HTTPPARSER);
}


Expand Down Expand Up @@ -488,6 +489,7 @@ class Parser : public AsyncWrap {

static void Unconsume(const FunctionCallbackInfo<Value>& args) {
Parser* parser = Unwrap<Parser>(args.Holder());
parser->DestroyAsyncWrap();

// Already unconsumed
if (parser->prev_alloc_cb_.is_empty())
Expand Down

0 comments on commit 64082db

Please sign in to comment.