Skip to content
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

Conversation

MoonBall
Copy link
Member

@MoonBall MoonBall commented Jan 14, 2018

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.

In onCorkedFinish(), state.corkedRequestsFree of a writable
stream is never null.

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • commit message follows commit guidelines
Affected core subsystem(s)

stream

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.
@nodejs-github-bot nodejs-github-bot added the stream Issues and PRs related to the stream subsystem. label Jan 14, 2018
@jasnell jasnell requested a review from mcollina January 14, 2018 21:42
`state.corkedRequestsFree` of a writable stream is always not null.
Copy link
Member

@mcollina mcollina left a 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;
Copy link
Member

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?

Copy link
Member Author

@MoonBall MoonBall Jan 17, 2018

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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My bad. I'm very scared of #6164 and #6154

@@ -579,7 +578,7 @@ Writable.prototype.end = function(chunk, encoding, cb) {
}

// ignore unnecessary end() calls.
if (!state.ending && !state.finished)
if (!state.ending)
Copy link
Member

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?

Copy link
Member Author

@MoonBall MoonBall Jan 17, 2018

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:

  1. if state.finished is true, state.ending must be true:
    !state.ending && !state.finished equals false && false.
    !state.ending equals false.
    !state.ending && !state.finished equals !state.ending.
  2. 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 &&
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this unused?

Copy link
Member Author

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
Copy link
Member

@BridgeAR
Copy link
Member

BridgeAR commented Feb 1, 2018

@mcollina PTAL

@mcollina
Copy link
Member

mcollina commented Feb 1, 2018

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mcollina
Copy link
Member

mcollina commented Feb 2, 2018

Landed as ce83099 and fca1c55

@mcollina mcollina closed this Feb 2, 2018
mcollina pushed a commit that referenced this pull request Feb 2, 2018
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>
mcollina pushed a commit that referenced this pull request Feb 2, 2018
`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>
MylesBorins pushed a commit that referenced this pull request Feb 20, 2018
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>
MylesBorins pushed a commit that referenced this pull request Feb 20, 2018
`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>
MylesBorins pushed a commit that referenced this pull request Feb 21, 2018
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>
MylesBorins pushed a commit that referenced this pull request Feb 21, 2018
`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>
MylesBorins pushed a commit that referenced this pull request Feb 21, 2018
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>
MylesBorins pushed a commit that referenced this pull request Feb 21, 2018
`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>
@MylesBorins MylesBorins mentioned this pull request Feb 21, 2018
@MylesBorins
Copy link
Contributor

Should this land on LTS? It lands cleanly on 8.x, but will require a backport for 6.x

MayaLekova pushed a commit to MayaLekova/node that referenced this pull request May 8, 2018
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>
MayaLekova pushed a commit to MayaLekova/node that referenced this pull request May 8, 2018
`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>
@MylesBorins
Copy link
Contributor

I've landed on 8.x @nodejs/streams @mcollina please lmk if it should be backed out

MylesBorins pushed a commit that referenced this pull request May 23, 2018
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>
MylesBorins pushed a commit that referenced this pull request May 23, 2018
`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>
@mcollina
Copy link
Member

This can be backported.

MylesBorins pushed a commit that referenced this pull request Jun 14, 2018
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>
MylesBorins pushed a commit that referenced this pull request Jun 14, 2018
`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>
@MylesBorins MylesBorins mentioned this pull request Jul 9, 2018
rvagg pushed a commit that referenced this pull request Aug 16, 2018
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>
rvagg pushed a commit that referenced this pull request Aug 16, 2018
`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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stream Issues and PRs related to the stream subsystem.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants