diff options
author | Anna Henningsen <anna@addaleax.net> | 2016-06-05 14:28:11 +0300 |
---|---|---|
committer | Anna Henningsen <anna@addaleax.net> | 2016-06-14 00:41:23 +0300 |
commit | e2e615e87e52773274619d0167716a766c16ac64 (patch) | |
tree | 92ac71d3145b8a25baeb89ac4d47220d7c300697 /benchmark/url | |
parent | 5fd6d75c4442123a818701817c5fbbca925648e5 (diff) |
stream: reset awaitDrain after manual .resume()
Reset the `readableState.awaitDrain` counter after manual calls to
`.resume()`.
What might happen otherwise is that a slow consumer at the end of the
pipe could end up stalling the piping in the following scenario:
1. The writable stream indicates that its buffer is full.
2. This leads the readable stream to `pause()` and increase its
`awaitDrain` counter, which will be decreased by the writable’s next
`drain` event.
3. Something calls `.resume()` manually.
4. The readable continues to pipe to the writable, but once again
the writable stream indicates that the buffer is full.
5. The `awaitDrain` counter is thus increased again, but since it has
now been increased twice for a single piping destination, the next
`drain` event will not be able to reset `awaitDrain` to zero.
6. The pipe is stalled and no data is passed along anymore.
The solution in this commit is to reset the `awaitDrain` counter to
zero when `resume()` is called.
Fixes: https://github.com/nodejs/node/issues/7159
PR-URL: https://github.com/nodejs/node/pull/7160
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'benchmark/url')
0 files changed, 0 insertions, 0 deletions