diff options
author | Anna Henningsen <anna@addaleax.net> | 2018-01-25 02:43:06 +0300 |
---|---|---|
committer | Ruben Bridgewater <ruben@bridgewater.de> | 2018-02-01 12:53:53 +0300 |
commit | 5898dc3d0c071a8e5135ba0a80565dd19d49cb32 (patch) | |
tree | 8bf1fd4236b183dfd8509b8d5bc43ec7f659f14a /src/stream_base.cc | |
parent | 7c4b09b24bbe7d6a8cbad256f47b30a101a909ea (diff) |
src: simplify handles for libuv streams
Instead of passing along the handle object, just set it as a
property on the stream handle object and let the read handler
grab it from there.
PR-URL: https://github.com/nodejs/node/pull/18334
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Diffstat (limited to 'src/stream_base.cc')
-rw-r--r-- | src/stream_base.cc | 23 |
1 files changed, 2 insertions, 21 deletions
diff --git a/src/stream_base.cc b/src/stream_base.cc index 9acf2273abd..8bdcebe88ab 100644 --- a/src/stream_base.cc +++ b/src/stream_base.cc @@ -437,23 +437,17 @@ void StreamBase::AfterWrite(WriteWrap* req_wrap, int status) { } -void StreamBase::CallJSOnreadMethod(ssize_t nread, - Local<Object> buf, - Local<Object> handle) { +void StreamBase::CallJSOnreadMethod(ssize_t nread, Local<Object> buf) { Environment* env = env_; Local<Value> argv[] = { Integer::New(env->isolate(), nread), - buf, - handle + buf }; if (argv[1].IsEmpty()) argv[1] = Undefined(env->isolate()); - if (argv[2].IsEmpty()) - argv[2] = Undefined(env->isolate()); - AsyncWrap* wrap = GetAsyncWrap(); CHECK_NE(wrap, nullptr); wrap->MakeCallback(env->onread_string(), arraysize(argv), argv); @@ -495,19 +489,6 @@ uv_buf_t StreamListener::OnStreamAlloc(size_t suggested_size) { return uv_buf_init(Malloc(suggested_size), suggested_size); } -void StreamListener::OnStreamRead(ssize_t nread, const uv_buf_t& buf) { - // This cannot be virtual because it is just as valid to override the other - // OnStreamRead() callback. - CHECK(0 && "OnStreamRead() needs to be implemented"); -} - -void StreamListener::OnStreamRead(ssize_t nread, - const uv_buf_t& buf, - uv_handle_type pending) { - CHECK_EQ(pending, UV_UNKNOWN_HANDLE); - OnStreamRead(nread, buf); -} - void EmitToJSStreamListener::OnStreamRead(ssize_t nread, const uv_buf_t& buf) { CHECK_NE(stream_, nullptr); |