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

Commit

Permalink
stream: use errorEmitted from _writableState
Browse files Browse the repository at this point in the history
  • Loading branch information
indutny authored and tjfontaine committed Feb 10, 2014
1 parent c0d81f9 commit e2a1d9a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions lib/_stream_writable.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ function WritableState(options, stream) {
this.prefinished = false;

// Internal, used in net.js and _tls_wrap.js
this._errorEmitted = false;
this.errorEmitted = false;
}

function Writable(options) {
Expand Down Expand Up @@ -274,8 +274,8 @@ function onwriteError(stream, state, sync, er, cb) {
cb(er);
}

stream._writableState.errorEmitted = true;
stream.emit('error', er);
stream._errorEmitted = true;
}

function onwriteStateUpdate(state) {
Expand Down
4 changes: 2 additions & 2 deletions lib/_tls_wrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,9 +238,9 @@ TLSSocket.prototype._init = function(socket) {
}

this.ssl.onerror = function(err) {
if (self._errorEmitted)
if (self._writableState.errorEmitted)
return;
self._errorEmitted = true;
self._writableState.errorEmitted = true;

// Destroy socket if error happened before handshake's finish
if (!this._secureEstablished) {
Expand Down
4 changes: 2 additions & 2 deletions lib/net.js
Original file line number Diff line number Diff line change
Expand Up @@ -428,11 +428,11 @@ Socket.prototype._destroy = function(exception, cb) {

function fireErrorCallbacks() {
if (cb) cb(exception);
if (exception && !self._errorEmitted) {
if (exception && !self._writableState.errorEmitted) {
process.nextTick(function() {
self.emit('error', exception);
});
self._errorEmitted = true;
self._writableState.errorEmitted = true;
}
};

Expand Down

0 comments on commit e2a1d9a

Please sign in to comment.