Browse Source

stream: use `errorEmitted` from `_writableState`

v0.11.12-release
Fedor Indutny 11 years ago
committed by Timothy J Fontaine
parent
commit
e2a1d9a9ac
  1. 4
      lib/_stream_writable.js
  2. 4
      lib/_tls_wrap.js
  3. 4
      lib/net.js

4
lib/_stream_writable.js

@ -117,7 +117,7 @@ function WritableState(options, stream) {
this.prefinished = false; this.prefinished = false;
// Internal, used in net.js and _tls_wrap.js // Internal, used in net.js and _tls_wrap.js
this._errorEmitted = false; this.errorEmitted = false;
} }
function Writable(options) { function Writable(options) {
@ -274,8 +274,8 @@ function onwriteError(stream, state, sync, er, cb) {
cb(er); cb(er);
} }
stream._writableState.errorEmitted = true;
stream.emit('error', er); stream.emit('error', er);
stream._errorEmitted = true;
} }
function onwriteStateUpdate(state) { function onwriteStateUpdate(state) {

4
lib/_tls_wrap.js

@ -238,9 +238,9 @@ TLSSocket.prototype._init = function(socket) {
} }
this.ssl.onerror = function(err) { this.ssl.onerror = function(err) {
if (self._errorEmitted) if (self._writableState.errorEmitted)
return; return;
self._errorEmitted = true; self._writableState.errorEmitted = true;
// Destroy socket if error happened before handshake's finish // Destroy socket if error happened before handshake's finish
if (!this._secureEstablished) { if (!this._secureEstablished) {

4
lib/net.js

@ -428,11 +428,11 @@ Socket.prototype._destroy = function(exception, cb) {
function fireErrorCallbacks() { function fireErrorCallbacks() {
if (cb) cb(exception); if (cb) cb(exception);
if (exception && !self._errorEmitted) { if (exception && !self._writableState.errorEmitted) {
process.nextTick(function() { process.nextTick(function() {
self.emit('error', exception); self.emit('error', exception);
}); });
self._errorEmitted = true; self._writableState.errorEmitted = true;
} }
}; };

Loading…
Cancel
Save