summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorLuigi Pinca <luigipinca@gmail.com>2018-02-23 10:52:25 +0100
committerAnatoli Papirovski <apapirovski@mac.com>2018-03-04 13:30:20 +0100
commitf2b9805f85d3ff770892b37944a0890e0e60ca78 (patch)
treeea729029f2ffd908505bdae918f6add1582d5100 /lib
parent584cfc9bae47197811126180c64f1983cad506ed (diff)
downloadandroid-node-v8-f2b9805f85d3ff770892b37944a0890e0e60ca78.tar.gz
android-node-v8-f2b9805f85d3ff770892b37944a0890e0e60ca78.tar.bz2
android-node-v8-f2b9805f85d3ff770892b37944a0890e0e60ca78.zip
stream: add no-half-open enforcer only if needed
The listener does not do anything if `allowHalfOpen` is enabled. Add it only when `allowHalfOpen` is disabled. PR-URL: https://github.com/nodejs/node/pull/18953 Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/_stream_duplex.js11
1 files changed, 5 insertions, 6 deletions
diff --git a/lib/_stream_duplex.js b/lib/_stream_duplex.js
index 288b8b538c..59ce832927 100644
--- a/lib/_stream_duplex.js
+++ b/lib/_stream_duplex.js
@@ -58,10 +58,10 @@ function Duplex(options) {
this.writable = false;
this.allowHalfOpen = true;
- if (options && options.allowHalfOpen === false)
+ if (options && options.allowHalfOpen === false) {
this.allowHalfOpen = false;
-
- this.once('end', onend);
+ this.once('end', onend);
+ }
}
Object.defineProperty(Duplex.prototype, 'writableHighWaterMark', {
@@ -96,9 +96,8 @@ Object.defineProperty(Duplex.prototype, 'writableLength', {
// the no-half-open enforcer
function onend() {
- // if we allow half-open state, or if the writable side ended,
- // then we're ok.
- if (this.allowHalfOpen || this._writableState.ended)
+ // If the writable side ended, then we're ok.
+ if (this._writableState.ended)
return;
// no more data can be written.