From 3533378d32b647b8fcb98a152a6ef39b16d4058b Mon Sep 17 00:00:00 2001 From: Fedor Indutny Date: Tue, 19 May 2015 13:18:42 +0200 Subject: [PATCH] tls_wrap: invoke queued callbacks in DestroySSL --- src/tls_wrap.cc | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/tls_wrap.cc b/src/tls_wrap.cc index ca0690defbd13b..b8a648de923081 100644 --- a/src/tls_wrap.cc +++ b/src/tls_wrap.cc @@ -86,12 +86,6 @@ TLSWrap::~TLSWrap() { sni_context_.Reset(); #endif // SSL_CTRL_SET_TLSEXT_SERVERNAME_CB - // Move all writes to pending - MakePending(); - - // And destroy - InvokeQueued(UV_ECANCELED); - ClearError(); } @@ -770,7 +764,16 @@ void TLSWrap::EnableSessionCallbacks( void TLSWrap::DestroySSL(const FunctionCallbackInfo& args) { TLSWrap* wrap = Unwrap(args.Holder()); + + // Move all writes to pending + wrap->MakePending(); + + // And destroy + wrap->InvokeQueued(UV_ECANCELED); + + // Destroy the SSL structure and friends wrap->SSLWrap::DestroySSL(); + delete wrap->clear_in_; wrap->clear_in_ = nullptr; }