Skip to content

Commit

Permalink
stream_base: homogenize req_wrap_obj use
Browse files Browse the repository at this point in the history
Always use `req_wrap_obj` to allow calling `req->Done()` in stream
implementations.

PR-URL: #10184
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
  • Loading branch information
indutny committed Dec 19, 2016
1 parent 0b44384 commit 729fecf
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions src/stream_base.cc
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,8 @@ void StreamBase::AfterShutdown(ShutdownWrap* req_wrap, int status) {
req_wrap_obj
};

if (req_wrap->object()->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;
}
Expand Down Expand Up @@ -172,9 +170,8 @@ int StreamBase::Writev(const FunctionCallbackInfo<Value>& 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(),
Number::New(env->isolate(), bytes));
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) {
req_wrap_obj->Set(env->error_string(), OneByteString(env->isolate(), msg));
Expand Down Expand Up @@ -328,7 +325,7 @@ int StreamBase::WriteString(const FunctionCallbackInfo<Value>& 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(
Expand All @@ -338,7 +335,7 @@ int StreamBase::WriteString(const FunctionCallbackInfo<Value>& args) {
reinterpret_cast<uv_stream_t*>(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();
Expand Down Expand Up @@ -383,10 +380,8 @@ void StreamBase::AfterWrite(WriteWrap* req_wrap, int status) {
wrap->ClearError();
}

if (req_wrap->object()->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();
}
Expand Down

0 comments on commit 729fecf

Please sign in to comment.