Browse Source

TLS: Simplify error handling

v0.7.4-release
Ryan Dahl 14 years ago
parent
commit
3e58696c07
  1. 12
      lib/tls.js

12
lib/tls.js

@ -196,11 +196,7 @@ CryptoStream.prototype._push = function() {
chunkBytes = this._pusher(pool, bytesRead, pool.length - bytesRead);
if (this.pair._ssl && this.pair._ssl.error) {
if (this.pair._secureEstablished) {
this.pair._error();
} else {
this.pair._destroy();
}
return;
}
@ -277,11 +273,7 @@ CryptoStream.prototype._pull = function() {
var rv = this._puller(tmp);
if (this.pair._ssl && this.pair._ssl.error) {
if (this.pair._secureEstablished) {
this.pair._error();
} else {
this.pair._destroy();
}
return;
}
@ -500,6 +492,9 @@ SecurePair.prototype._destroy = function() {
SecurePair.prototype._error = function() {
if (!this._secureEstablished) {
this._destroy();
} else {
var err = this._ssl.error;
this._ssl.error = null;
@ -511,6 +506,7 @@ SecurePair.prototype._error = function() {
} else {
this.cleartext.emit('error', err);
}
}
};
// TODO: support anonymous (nocert) and PSK

Loading…
Cancel
Save