summaryrefslogtreecommitdiff
path: root/lib/tls.js
diff options
context:
space:
mode:
authorFedor Indutny <fedor.indutny@gmail.com>2012-01-24 00:30:28 +0600
committerFedor Indutny <fedor.indutny@gmail.com>2012-01-24 00:30:28 +0600
commit667aae596cded9336f50574386683ec39ada43f2 (patch)
tree41918ad8d4801cc34215b054cb63dc83bd1ce8a5 /lib/tls.js
parent2433eeb3850a91feb99bab530cb7183800166390 (diff)
parent6c0c00a2052ec613503a0322dcbabb6fcf41dab0 (diff)
downloadnodejs-667aae596cded9336f50574386683ec39ada43f2.tar.gz
nodejs-667aae596cded9336f50574386683ec39ada43f2.tar.bz2
nodejs-667aae596cded9336f50574386683ec39ada43f2.zip
Merge branch 'v0.6'
Conflicts: ChangeLog doc/template.html lib/cluster.js lib/http.js lib/tls.js src/node.h src/node_version.h test/simple/test-cluster-kill-workers.js
Diffstat (limited to 'lib/tls.js')
-rw-r--r--lib/tls.js19
1 files changed, 10 insertions, 9 deletions
diff --git a/lib/tls.js b/lib/tls.js
index c8f2ed27d..faf81c066 100644
--- a/lib/tls.js
+++ b/lib/tls.js
@@ -271,7 +271,11 @@ CryptoStream.prototype._done = function() {
this.pair.encrypted._doneFlag &&
!this.pair._doneFlag) {
// If both streams are done:
- this.pair.destroy();
+ if (!this.pair._secureEstablished) {
+ this.pair.error();
+ } else {
+ this.pair.destroy();
+ }
}
};
@@ -724,7 +728,6 @@ SecurePair.prototype.destroy = function() {
}
var self = this;
- var error = this.ssl.error;
this._doneFlag = true;
this.ssl.error = null;
@@ -739,20 +742,18 @@ SecurePair.prototype.destroy = function() {
self.encrypted.emit('close');
self.cleartext.emit('close');
});
+};
+
+SecurePair.prototype.error = function() {
if (!this._secureEstablished) {
+ var error = this.ssl.error;
if (!error) {
error = new Error('socket hang up');
error.code = 'ECONNRESET';
}
- this.emit('error', error);
- }
-};
-
-
-SecurePair.prototype.error = function() {
- if (!this._secureEstablished) {
this.destroy();
+ this.emit('error', error);
} else {
var err = this.ssl.error;
this.ssl.error = null;