tls: destroy singleUse context immediately
authorFedor Indutny <fedor@indutny.com>
Mon, 27 Apr 2015 07:39:48 +0000 (09:39 +0200)
committerFedor Indutny <fedor@indutny.com>
Thu, 30 Apr 2015 09:02:30 +0000 (11:02 +0200)
Destroy singleUse context right after it is going out of use.

Fix: https://github.com/iojs/io.js/issues/1522
PR-URL: https://github.com/iojs/io.js/pull/1529
Reviewed-By: Shigeki Ohtsu <ohtsu@iij.ad.jp>
lib/_tls_common.js
lib/_tls_wrap.js

index 3040b3a..d857717 100644 (file)
@@ -134,8 +134,10 @@ exports.createSecureContext = function createSecureContext(options, context) {
   }
 
   // Do not keep read/write buffers in free list
-  if (options.singleUse)
+  if (options.singleUse) {
+    c.singleUse = true;
     c.context.setFreeListLength(0);
+  }
 
   return c;
 };
index 7f83e2f..122c704 100644 (file)
@@ -301,7 +301,9 @@ TLSSocket.prototype._wrapHandle = function(handle) {
 };
 
 TLSSocket.prototype._destroySSL = function _destroySSL() {
-  return this.ssl.destroySSL();
+  this.ssl.destroySSL();
+  if (this.ssl._secureContext.singleUse)
+    this.ssl._secureContext.context.close();
 };
 
 TLSSocket.prototype._init = function(socket, wrap) {