diff options
author | Malte-Thorben Bruns <skenqbx@gmail.com> | 2015-05-22 21:12:59 +0200 |
---|---|---|
committer | Fedor Indutny <fedor@indutny.com> | 2015-05-22 21:30:22 +0200 |
commit | 2a71f02988244b6299db8fe8ba3cc0491793acfc (patch) | |
tree | ab902f89347410a9b6e429db2827d5af00e61a9d /lib | |
parent | 2bb2f06b3e53ca44687afdaa9b833e0b6181ff76 (diff) | |
download | node-new-2a71f02988244b6299db8fe8ba3cc0491793acfc.tar.gz |
tls: emit errors happening before handshake finish
This fixes a race condition introduced in 80342f6.
`socket.destroy(err)` only emits the passed error when
`socket._writableState.errorEmitted === false`, `ssl.onerror`
sets `errorEmitted = true` just before calling
`socket.destroy()`.
See: https://github.com/nodejs/io.js/issues/1119
See: https://github.com/nodejs/io.js/issues/1711
PR-URL: https://github.com/nodejs/io.js/pull/1769
Reviewed-By: Fedor Indutny <fedor@indutny.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/_tls_wrap.js | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/_tls_wrap.js b/lib/_tls_wrap.js index 544fe95206..b39cdb9a35 100644 --- a/lib/_tls_wrap.js +++ b/lib/_tls_wrap.js @@ -359,7 +359,6 @@ TLSSocket.prototype._init = function(socket, wrap) { ssl.onerror = function(err) { if (self._writableState.errorEmitted) return; - self._writableState.errorEmitted = true; // Destroy socket if error happened before handshake's finish if (!self._secureEstablished) { @@ -373,6 +372,8 @@ TLSSocket.prototype._init = function(socket, wrap) { // Throw error self._emitTLSError(err); } + + self._writableState.errorEmitted = true; }; // If custom SNICallback was given, or if |