From e920c4c8aaa9d008075401df591de40c729e19f2 Mon Sep 17 00:00:00 2001 From: Fedor Indutny Date: Thu, 8 Dec 2016 21:32:06 +0100 Subject: [PATCH 1/7] stream_base: homogenize req_wrap_obj use Always use `req_wrap_obj` to allow calling `req->Done()` in stream implementations. --- src/stream_base.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/stream_base.cc b/src/stream_base.cc index a12a1efc73be11..4b129f628c0fef 100644 --- a/src/stream_base.cc +++ b/src/stream_base.cc @@ -172,8 +172,8 @@ int StreamBase::Writev(const FunctionCallbackInfo& args) { int err = DoWrite(req_wrap, *bufs, count, nullptr); - req_wrap->object()->Set(env->async(), True(env->isolate())); - req_wrap->object()->Set(env->bytes_string(), + req_wrap_obj->Set(env->async(), True(env->isolate())); + req_wrap_obj->Set(env->bytes_string(), Number::New(env->isolate(), bytes)); const char* msg = Error(); if (msg != nullptr) { @@ -338,7 +338,7 @@ int StreamBase::WriteString(const FunctionCallbackInfo& args) { reinterpret_cast(send_handle)); } - req_wrap->object()->Set(env->async(), True(env->isolate())); + req_wrap_obj->Set(env->async(), True(env->isolate())); if (err) req_wrap->Dispose(); From 8fb61a761dc356168476c7b9d0372593306f3f68 Mon Sep 17 00:00:00 2001 From: Fedor Indutny Date: Thu, 8 Dec 2016 21:41:19 +0100 Subject: [PATCH 2/7] fix --- src/stream_base.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/stream_base.cc b/src/stream_base.cc index 4b129f628c0fef..73b89ae28a679a 100644 --- a/src/stream_base.cc +++ b/src/stream_base.cc @@ -174,7 +174,7 @@ int StreamBase::Writev(const FunctionCallbackInfo& args) { req_wrap_obj->Set(env->async(), True(env->isolate())); req_wrap_obj->Set(env->bytes_string(), - Number::New(env->isolate(), bytes)); + Number::New(env->isolate(), bytes)); const char* msg = Error(); if (msg != nullptr) { req_wrap_obj->Set(env->error_string(), OneByteString(env->isolate(), msg)); From 62be1418c9d9776c6b25aa20e75c9c908831783f Mon Sep 17 00:00:00 2001 From: Fedor Indutny Date: Thu, 8 Dec 2016 21:41:41 +0100 Subject: [PATCH 3/7] fix --- src/stream_base.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/stream_base.cc b/src/stream_base.cc index 73b89ae28a679a..fbfa1f2253dfd9 100644 --- a/src/stream_base.cc +++ b/src/stream_base.cc @@ -173,8 +173,7 @@ int StreamBase::Writev(const FunctionCallbackInfo& args) { int err = DoWrite(req_wrap, *bufs, count, nullptr); req_wrap_obj->Set(env->async(), True(env->isolate())); - req_wrap_obj->Set(env->bytes_string(), - Number::New(env->isolate(), bytes)); + req_wrap_obj->Set(env->bytes_string(), Number::New(env->isolate(), bytes)); const char* msg = Error(); if (msg != nullptr) { req_wrap_obj->Set(env->error_string(), OneByteString(env->isolate(), msg)); From acb49db577a67dd92d8e07aeb4a528206d30d6bf Mon Sep 17 00:00:00 2001 From: Fedor Indutny Date: Thu, 8 Dec 2016 21:45:25 +0100 Subject: [PATCH 4/7] fix --- src/stream_base.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/stream_base.cc b/src/stream_base.cc index fbfa1f2253dfd9..753098081dc1ca 100644 --- a/src/stream_base.cc +++ b/src/stream_base.cc @@ -327,7 +327,7 @@ int StreamBase::WriteString(const FunctionCallbackInfo& args) { // Reference StreamWrap instance to prevent it from being garbage // collected before `AfterWrite` is called. CHECK_EQ(false, req_wrap->persistent().IsEmpty()); - req_wrap->object()->Set(env->handle_string(), send_handle_obj); + req_wrap_obj->Set(env->handle_string(), send_handle_obj); } err = DoWrite( From 2d4705981cad3e65791230b4c424fdbcd7977053 Mon Sep 17 00:00:00 2001 From: Fedor Indutny Date: Thu, 8 Dec 2016 21:50:40 +0100 Subject: [PATCH 5/7] fix --- src/stream_base.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/stream_base.cc b/src/stream_base.cc index 753098081dc1ca..1ede73bc95e91d 100644 --- a/src/stream_base.cc +++ b/src/stream_base.cc @@ -82,7 +82,7 @@ void StreamBase::AfterShutdown(ShutdownWrap* req_wrap, int status) { req_wrap_obj }; - if (req_wrap->object()->Has(env->context(), + if (req_wrap_obj->Has(env->context(), env->oncomplete_string()).FromJust()) { req_wrap->MakeCallback(env->oncomplete_string(), arraysize(argv), argv); } @@ -382,7 +382,7 @@ void StreamBase::AfterWrite(WriteWrap* req_wrap, int status) { wrap->ClearError(); } - if (req_wrap->object()->Has(env->context(), + if (req_wrap_obj->Has(env->context(), env->oncomplete_string()).FromJust()) { req_wrap->MakeCallback(env->oncomplete_string(), arraysize(argv), argv); } From 40ecba1a0e2356c356718010bcacfc435c884e97 Mon Sep 17 00:00:00 2001 From: Fedor Indutny Date: Thu, 8 Dec 2016 21:51:50 +0100 Subject: [PATCH 6/7] fix --- src/stream_base.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/stream_base.cc b/src/stream_base.cc index 1ede73bc95e91d..4f2014162d9f26 100644 --- a/src/stream_base.cc +++ b/src/stream_base.cc @@ -82,8 +82,7 @@ void StreamBase::AfterShutdown(ShutdownWrap* req_wrap, int status) { req_wrap_obj }; - if (req_wrap_obj->Has(env->context(), - env->oncomplete_string()).FromJust()) { + if (req_wrap_obj->Has(env->context(), env->oncomplete_string()).FromJust()) { req_wrap->MakeCallback(env->oncomplete_string(), arraysize(argv), argv); } From ddbe078dee44477d97bdbb221a8bf2708e5cbbd3 Mon Sep 17 00:00:00 2001 From: Fedor Indutny Date: Thu, 8 Dec 2016 21:52:09 +0100 Subject: [PATCH 7/7] fix --- src/stream_base.cc | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/stream_base.cc b/src/stream_base.cc index 4f2014162d9f26..3ed622d7ef35a2 100644 --- a/src/stream_base.cc +++ b/src/stream_base.cc @@ -82,9 +82,8 @@ void StreamBase::AfterShutdown(ShutdownWrap* req_wrap, int status) { req_wrap_obj }; - if (req_wrap_obj->Has(env->context(), env->oncomplete_string()).FromJust()) { + if (req_wrap_obj->Has(env->context(), env->oncomplete_string()).FromJust()) req_wrap->MakeCallback(env->oncomplete_string(), arraysize(argv), argv); - } delete req_wrap; } @@ -381,10 +380,8 @@ void StreamBase::AfterWrite(WriteWrap* req_wrap, int status) { wrap->ClearError(); } - if (req_wrap_obj->Has(env->context(), - env->oncomplete_string()).FromJust()) { + if (req_wrap_obj->Has(env->context(), env->oncomplete_string()).FromJust()) req_wrap->MakeCallback(env->oncomplete_string(), arraysize(argv), argv); - } req_wrap->Dispose(); }