From 64082dbcbf714522ba31e75e09bebf8300819522 Mon Sep 17 00:00:00 2001 From: Owen Smith Date: Tue, 22 Mar 2016 14:15:29 -0400 Subject: [PATCH] async_wrap,http: handle init/destroy lifecycle within HttpParser --- src/node_http_parser.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/node_http_parser.cc b/src/node_http_parser.cc index 0b363ca6c310f7..93296e7c0cf77e 100644 --- a/src/node_http_parser.cc +++ b/src/node_http_parser.cc @@ -150,7 +150,7 @@ struct StringPtr { class Parser : public AsyncWrap { public: Parser(Environment* env, Local 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); @@ -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); } @@ -488,6 +489,7 @@ class Parser : public AsyncWrap { static void Unconsume(const FunctionCallbackInfo& args) { Parser* parser = Unwrap(args.Holder()); + parser->DestroyAsyncWrap(); // Already unconsumed if (parser->prev_alloc_cb_.is_empty())