Browse Source

stream_base: homogenize req_wrap_obj use

Always use `req_wrap_obj` to allow calling `req->Done()` in stream
implementations.

PR-URL: https://github.com/nodejs/node/pull/10184
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
v6
Fedor Indutny 8 years ago
parent
commit
729fecf390
  1. 17
      src/stream_base.cc

17
src/stream_base.cc

@ -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;
}
@ -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));
@ -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(
@ -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();
@ -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();
}

Loading…
Cancel
Save