Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
tls: fix test-https-client-reject fails
Browse files Browse the repository at this point in the history
Fixes #2417.
  • Loading branch information
koichik committed Dec 27, 2011
1 parent e6b6075 commit b962ff3
Showing 1 changed file with 20 additions and 18 deletions.
38 changes: 20 additions & 18 deletions lib/tls.js
Expand Up @@ -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);
}
};

Expand Down

0 comments on commit b962ff3

Please sign in to comment.