-
-
Notifications
You must be signed in to change notification settings - Fork 35.4k
Cleanup stream state in net #465
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
f5c5ebe
1d8ad7d
0e02aaf
cc402e5
30cce39
f05d1eb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -117,6 +117,7 @@ function initSocketHandle(self) { | |
| function Socket(options) { | ||
| if (!(this instanceof Socket)) return new Socket(options); | ||
|
|
||
| this._errorEmitted = false; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see, you moved it here. |
||
| this._connecting = false; | ||
| this._hadError = false; | ||
| this._handle = null; | ||
|
|
@@ -420,12 +421,14 @@ Socket.prototype._destroy = function(exception, cb) { | |
| var self = this; | ||
|
|
||
| function fireErrorCallbacks() { | ||
| var hadSeenError = self._errorEmitted; | ||
| self._errorEmitted = self._errorEmitted || Boolean(exception); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please replace
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is the reason of introducing it here?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This moves the
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, if you mean |
||
| if (cb) cb(exception); | ||
| if (exception && !self._writableState.errorEmitted) { | ||
| else if (exception && !hadSeenError) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This code style does look a bit different from what we usually do. Why not: if (cb) {
cb(exception);
} else if (...) {
}?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, since it was a single ExpressionStatement I preserved the braceless |
||
| process.nextTick(function() { | ||
| self.emit('error', exception); | ||
| }); | ||
| self._writableState.errorEmitted = true; | ||
| self._errorEmitted = true; | ||
| } | ||
| }; | ||
|
|
||
|
|
@@ -840,7 +843,7 @@ Socket.prototype.connect = function(options, cb) { | |
| this._writableState.ended = false; | ||
| this._writableState.ending = false; | ||
| this._writableState.finished = false; | ||
| this._writableState.errorEmitted = false; | ||
| this._errorEmitted = false; | ||
| this.destroyed = false; | ||
| this._handle = null; | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm... This was a bug fix, as far as I remember. Why doesn't it apply anymore?