tls: destroy singleUse context immediately

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>
This commit is contained in:
Fedor Indutny 2015-04-27 09:39:48 +02:00
parent 2684c902c4
commit 1787416376
2 changed files with 6 additions and 2 deletions

View 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;
};

View 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) {