summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorRobert Nagy <ronagy@icloud.com>2019-10-03 20:53:58 +0200
committerRich Trott <rtrott@gmail.com>2019-10-05 17:43:21 -0700
commitf58e8eb103ff30876198946a4a9c1280b987c1fb (patch)
tree07c7004c14d808a3a130a3c79745eb3244efb4ef /lib
parent0b495a899bdf9a26b25a6e31177512531c841e0e (diff)
downloadandroid-node-v8-f58e8eb103ff30876198946a4a9c1280b987c1fb.tar.gz
android-node-v8-f58e8eb103ff30876198946a4a9c1280b987c1fb.tar.bz2
android-node-v8-f58e8eb103ff30876198946a4a9c1280b987c1fb.zip
stream: do not deadlock duplexpair
If nothing is buffered then _read will not be called and the callback will not be invoked, effectivly deadlocking. Fixes: https://github.com/nodejs/node/issues/29758 PR-URL: https://github.com/nodejs/node/pull/29836 Refs: https://github.com/nodejs/node/pull/29649 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Minwoo Jung <minwoo@nodesource.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/internal/streams/duplexpair.js8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/internal/streams/duplexpair.js b/lib/internal/streams/duplexpair.js
index beaf9e9eb3..6735bcb2b9 100644
--- a/lib/internal/streams/duplexpair.js
+++ b/lib/internal/streams/duplexpair.js
@@ -20,8 +20,12 @@ class DuplexSocket extends Duplex {
}
_write(chunk, encoding, callback) {
- this[kOtherSide][kCallback] = callback;
- this[kOtherSide].push(chunk);
+ if (chunk.length === 0) {
+ process.nextTick(callback);
+ } else {
+ this[kOtherSide].push(chunk);
+ this[kOtherSide][kCallback] = callback;
+ }
}
_final(callback) {