-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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
stream: delete redundant code #18145
stream: delete redundant code #18145
Conversation
In `Writable.prototype.end()`, `state.ending` is true after calling `endWritable()` and it doesn't reset to false. In `Writable.prototype.uncork()`, `state.finished` must be false if `state.bufferedRequest` is true.
`state.corkedRequestsFree` of a writable stream is always not 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.
Thanks for contributing! I've left some questions/notes around the PR.
} | ||
|
||
// reuse the free corkReq. | ||
state.corkedRequestsFree.next = corkReq; |
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.
Unfortunately, this can end up being null
because it copied over in: https://github.com/MoonBall/node/blob/dd13a79b830ef2d33ac0288e197a431a63e40941/lib/_stream_writable.js#L517. Can you revert this?
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.
if (holder.next)
can ensure that state.corkedRequestsFree
is not 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.
@@ -579,7 +578,7 @@ Writable.prototype.end = function(chunk, encoding, cb) { | |||
} | |||
|
|||
// ignore unnecessary end() calls. | |||
if (!state.ending && !state.finished) | |||
if (!state.ending) |
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.
This is actually a behavior change. Can you add a unit test?
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.
state.finished = true
is only in finishMaybe()
. If we simplify the finishMaybe()
, it should be:
function finishMaybe(stream, state) {
if (state.ending) {
state.finished = true;
}
}
And, state.ending
doesn't set to false.
So:
- if
state.finished
is true,state.ending
must be true:
!state.ending && !state.finished
equalsfalse && false
.
!state.ending
equalsfalse
.
!state.ending && !state.finished
equals!state.ending
. - if
state.finished
is false:
!state.ending && !state.finished
equals!state.ending && true
.
!state.ending && !state.finished
equals!state.ending
.
@@ -307,7 +307,6 @@ Writable.prototype.uncork = function() { | |||
|
|||
if (!state.writing && | |||
!state.corked && | |||
!state.finished && |
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.
why is this unused?
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.
state.finished
should equal false
if state.bufferedRequest
isn't null
.
@mcollina PTAL |
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.
LGTM
In `Writable.prototype.end()`, `state.ending` is true after calling `endWritable()` and it doesn't reset to false. In `Writable.prototype.uncork()`, `state.finished` must be false if `state.bufferedRequest` is true. PR-URL: #18145 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
`state.corkedRequestsFree` of a writable stream is always not null. PR-URL: #18145 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
In `Writable.prototype.end()`, `state.ending` is true after calling `endWritable()` and it doesn't reset to false. In `Writable.prototype.uncork()`, `state.finished` must be false if `state.bufferedRequest` is true. PR-URL: #18145 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
`state.corkedRequestsFree` of a writable stream is always not null. PR-URL: #18145 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
In `Writable.prototype.end()`, `state.ending` is true after calling `endWritable()` and it doesn't reset to false. In `Writable.prototype.uncork()`, `state.finished` must be false if `state.bufferedRequest` is true. PR-URL: #18145 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
`state.corkedRequestsFree` of a writable stream is always not null. PR-URL: #18145 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
In `Writable.prototype.end()`, `state.ending` is true after calling `endWritable()` and it doesn't reset to false. In `Writable.prototype.uncork()`, `state.finished` must be false if `state.bufferedRequest` is true. PR-URL: #18145 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
`state.corkedRequestsFree` of a writable stream is always not null. PR-URL: #18145 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Should this land on LTS? It lands cleanly on 8.x, but will require a backport for 6.x |
In `Writable.prototype.end()`, `state.ending` is true after calling `endWritable()` and it doesn't reset to false. In `Writable.prototype.uncork()`, `state.finished` must be false if `state.bufferedRequest` is true. PR-URL: nodejs#18145 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
`state.corkedRequestsFree` of a writable stream is always not null. PR-URL: nodejs#18145 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
I've landed on 8.x @nodejs/streams @mcollina please lmk if it should be backed out |
In `Writable.prototype.end()`, `state.ending` is true after calling `endWritable()` and it doesn't reset to false. In `Writable.prototype.uncork()`, `state.finished` must be false if `state.bufferedRequest` is true. PR-URL: #18145 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
`state.corkedRequestsFree` of a writable stream is always not null. PR-URL: #18145 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
This can be backported. |
In `Writable.prototype.end()`, `state.ending` is true after calling `endWritable()` and it doesn't reset to false. In `Writable.prototype.uncork()`, `state.finished` must be false if `state.bufferedRequest` is true. PR-URL: #18145 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
`state.corkedRequestsFree` of a writable stream is always not null. PR-URL: #18145 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
In `Writable.prototype.end()`, `state.ending` is true after calling `endWritable()` and it doesn't reset to false. In `Writable.prototype.uncork()`, `state.finished` must be false if `state.bufferedRequest` is true. PR-URL: #18145 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
`state.corkedRequestsFree` of a writable stream is always not null. PR-URL: #18145 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
In
Writable.prototype.end()
,state.ending
is true after callingendWritable()
and it doesn't reset to false.In
Writable.prototype.uncork()
,state.finished
must be falseif
state.bufferedRequest
is true.In
onCorkedFinish()
,state.corkedRequestsFree
of a writablestream is never null.
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)
stream