diff options
author | jBarz <jbarboza@ca.ibm.com> | 2017-03-09 08:33:59 -0500 |
---|---|---|
committer | James M Snell <jasnell@gmail.com> | 2017-03-16 16:24:07 -0700 |
commit | 4cdb0e89d8daf7e1371c3b8d3f057940aa327d4a (patch) | |
tree | be4bd839b2144fd0eab50eff62976c6f8a4d3ce1 /src/tls_wrap.cc | |
parent | 303962aca192e28b5ec5a74da9f53d9f26e52359 (diff) | |
download | android-node-v8-4cdb0e89d8daf7e1371c3b8d3f057940aa327d4a.tar.gz android-node-v8-4cdb0e89d8daf7e1371c3b8d3f057940aa327d4a.tar.bz2 android-node-v8-4cdb0e89d8daf7e1371c3b8d3f057940aa327d4a.zip |
tls: keep track of stream that is closed
TLSWrap object keeps a pointer reference to the underlying
TCPWrap object. This TCPWrap object could be closed and deleted
by the event-loop which leaves us with a dangling pointer.
So the TLSWrap object needs to track the "close" event on the
TCPWrap object.
PR-URL: https://github.com/nodejs/node/pull/11776
Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Brian White <mscdex@mscdex.net>
Diffstat (limited to 'src/tls_wrap.cc')
-rw-r--r-- | src/tls_wrap.cc | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/tls_wrap.cc b/src/tls_wrap.cc index e23e686b9d..ad6daa4301 100644 --- a/src/tls_wrap.cc +++ b/src/tls_wrap.cc @@ -543,7 +543,7 @@ int TLSWrap::GetFD() { bool TLSWrap::IsAlive() { - return ssl_ != nullptr && stream_->IsAlive(); + return ssl_ != nullptr && stream_ != nullptr && stream_->IsAlive(); } @@ -802,6 +802,14 @@ void TLSWrap::EnableSessionCallbacks( } +void TLSWrap::OnStreamClose(const FunctionCallbackInfo<Value>& args) { + TLSWrap* wrap; + ASSIGN_OR_RETURN_UNWRAP(&wrap, args.Holder()); + + wrap->stream_ = nullptr; +} + + void TLSWrap::DestroySSL(const FunctionCallbackInfo<Value>& args) { TLSWrap* wrap; ASSIGN_OR_RETURN_UNWRAP(&wrap, args.Holder()); @@ -932,6 +940,7 @@ void TLSWrap::Initialize(Local<Object> target, env->SetProtoMethod(t, "enableSessionCallbacks", EnableSessionCallbacks); env->SetProtoMethod(t, "destroySSL", DestroySSL); env->SetProtoMethod(t, "enableCertCb", EnableCertCb); + env->SetProtoMethod(t, "onStreamClose", OnStreamClose); StreamBase::AddMethods<TLSWrap>(env, t, StreamBase::kFlagHasWritev); SSLWrap<TLSWrap>::AddMethods(env, t); |