Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 36.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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
f5c5ebe1d8ad7d0e02aafcc402e530cce39f05d1ebFile filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -306,9 +306,9 @@ TLSSocket.prototype._init = function(socket) { | ||
| } | ||
| this.ssl.onerror = function(err) { | ||
| if (self._writableState.errorEmitted) | ||
| if (self._errorEmitted) | ||
| return; | ||
| self._writableState.errorEmitted = true; | ||
| self._errorEmitted = true; | ||
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. Hm... This was a bug fix, as far as I remember. Why doesn't it apply anymore? | ||
| // Destroy socket if error happened before handshake's finish | ||
| if (!this._secureEstablished) { | ||
| 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; | ||
| @@ -127,6 +128,8 @@ function Socket(options) { | ||
| else if (options === undefined) | ||
| options = {}; | ||
| // handle strings directly | ||
| options.decodeStrings = false; | ||
| stream.Duplex.call(this, options); | ||
| if (options.handle) { | ||
| @@ -158,9 +161,6 @@ function Socket(options) { | ||
| this._pendingData = null; | ||
| this._pendingEncoding = ''; | ||
| // handle strings directly | ||
| this._writableState.decodeStrings = false; | ||
| // default to *not* allowing half open sockets | ||
| this.allowHalfOpen = options && options.allowHalfOpen || false; | ||
| @@ -171,7 +171,7 @@ function Socket(options) { | ||
| // stop the handle from reading and pause the stream | ||
| this._handle.reading = false; | ||
| this._handle.readStop(); | ||
| this._readableState.flowing = false; | ||
| this.pause(); | ||
| } else { | ||
| this.read(0); | ||
| } | ||
| @@ -193,11 +193,10 @@ function onSocketFinish() { | ||
| } | ||
| debug('onSocketFinish'); | ||
| if (!this.readable || this._readableState.ended) { | ||
| if (!this.readable) { | ||
| debug('oSF: ended, destroy', this._readableState); | ||
| return this.destroy(); | ||
| } | ||
| debug('oSF: not ended, call shutdown()'); | ||
| // otherwise, just shutdown, or destroy() if not possible | ||
| @@ -239,13 +238,10 @@ function onSocketEnd() { | ||
| // ended should already be true, since this is called *after* | ||
| // the EOF errno and onread has eof'ed | ||
| debug('onSocketEnd', this._readableState); | ||
| this._readableState.ended = true; | ||
| if (this._readableState.endEmitted) { | ||
| this.readable = false; | ||
| maybeDestroy(this); | ||
| } else { | ||
| this.once('end', function() { | ||
| this.readable = false; | ||
| maybeDestroy(this); | ||
| }); | ||
| this.read(0); | ||
| @@ -425,12 +421,15 @@ Socket.prototype._destroy = function(exception, cb) { | ||
| var self = this; | ||
| function fireErrorCallbacks() { | ||
| if (cb) cb(exception); | ||
| if (exception && !self._writableState.errorEmitted) { | ||
| var hadSeenError = self._errorEmitted; | ||
| self._errorEmitted = self._errorEmitted || !!(exception); | ||
| if (cb) { | ||
| cb(exception); | ||
| } else if (exception && !hadSeenError) { | ||
| process.nextTick(function() { | ||
| self.emit('error', exception); | ||
| }); | ||
| self._writableState.errorEmitted = true; | ||
| self._errorEmitted = true; | ||
| } | ||
| }; | ||
| @@ -845,7 +844,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... doesn't look like it belong here.