tls_wrap: Unlink TLSWrap and SecureContext objects
This makes `TLSWrap` and `SecureContext` objects collectable by the incremental gc. `res = null` destroys the cyclic reference in the `reading` property. `this.ssl = null` removes the remaining reference to the `TLSWrap`. `this.ssl._secureContext.context = null` removes the reference to the `SecureContext` object, even though there might be references to `this.ssl._secureContext` somewhere. The `reading` property will now throw an error if accessed after the socket is closed, but that should not happen. PR-URL: https://github.com/iojs/io.js/pull/1580 Reviewed-By: Fedor Indutny <fedor@indutny.com> Reviewed-By: Shigeki Ohtsu <ohtsu@iij.ad.jp>
This commit is contained in:
parent
dacc1fa35c
commit
f7620fb96d
@ -289,15 +289,22 @@ TLSSocket.prototype._wrapHandle = function(handle) {
|
||||
}
|
||||
});
|
||||
|
||||
this.on('close', this._destroySSL);
|
||||
this.on('close', function() {
|
||||
this._destroySSL();
|
||||
res = null;
|
||||
});
|
||||
|
||||
return res;
|
||||
};
|
||||
|
||||
TLSSocket.prototype._destroySSL = function _destroySSL() {
|
||||
if (!this.ssl) return;
|
||||
this.ssl.destroySSL();
|
||||
if (this.ssl._secureContext.singleUse)
|
||||
if (this.ssl._secureContext.singleUse) {
|
||||
this.ssl._secureContext.context.close();
|
||||
this.ssl._secureContext.context = null;
|
||||
}
|
||||
this.ssl = null;
|
||||
};
|
||||
|
||||
TLSSocket.prototype._init = function(socket, wrap) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user