tls: fix test-https-client-reject fails

Fixes #2417.
This commit is contained in:
koichik 2011-12-27 17:33:23 +09:00
parent e6b6075024
commit b962ff35dd

View File

@ -719,31 +719,33 @@ SecurePair.prototype.maybeInitFinished = function() {
SecurePair.prototype.destroy = function() {
if (this._doneFlag) {
return;
}
var self = this;
var error = this.ssl.error;
if (!this._doneFlag) {
this._doneFlag = true;
this.ssl.error = null;
this.ssl.close();
this.ssl = null;
this._doneFlag = true;
this.ssl.error = null;
this.ssl.close();
this.ssl = null;
self.encrypted.writable = self.encrypted.readable = false;
self.cleartext.writable = self.cleartext.readable = false;
self.encrypted.writable = self.encrypted.readable = false;
self.cleartext.writable = self.cleartext.readable = false;
process.nextTick(function() {
self.cleartext.emit('end');
self.encrypted.emit('close');
self.cleartext.emit('close');
});
process.nextTick(function() {
self.cleartext.emit('end');
self.encrypted.emit('close');
self.cleartext.emit('close');
});
if (!this._secureEstablished) {
if (!error) {
error = new Error('socket hang up');
error.code = 'ECONNRESET';
}
this.emit('error', error);
if (!this._secureEstablished) {
if (!error) {
error = new Error('socket hang up');
error.code = 'ECONNRESET';
}
this.emit('error', error);
}
};