Skip to content

Commit

Permalink
tls: destroy singleUse context immediately
Browse files Browse the repository at this point in the history
Destroy singleUse context right after it is going out of use.

Fix: #1522
  • Loading branch information
indutny committed Apr 27, 2015
1 parent b08781c commit 7470588
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion lib/_tls_common.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
Expand Down
4 changes: 3 additions & 1 deletion lib/_tls_wrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 7470588

Please sign in to comment.