child_process: fix stdio sockets creation

`readable` and `writable` properties can be passed directly to the
`net.Socket` constructor. This change also avoids an unnecessary call
to `read(0)` on the `stdin` socket. This behavior was disclosed when
trying to merge `libuv@1.19.0` and specifically this commit:
https://github.com/libuv/libuv/commit/fd049399aa4ed8495928e375466970d98cb42e17.

PR-URL: https://github.com/nodejs/node/pull/18701
Refs: https://github.com/libuv/libuv/pull/1655
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
This commit is contained in:
Santiago Gimeno authored and Myles Borins committed 2018-02-21 14:20:29 -05:00
1 parent 0fc33fb282
commit 91f2cf9297
2 files changed
+2 -12

No files matched your search

+1 -11
View File
@@ -238,17 +238,7 @@ function flushStdio(subprocess) {
function createSocket(pipe, readable) {
var s = new net.Socket({ handle: pipe });
if (readable) {
s.writable = false;
s.readable = true;
} else {
s.writable = true;
s.readable = false;
}
return s;
return net.Socket({ handle: pipe, readable, writable: !readable });
}
+1 -1
View File
@@ -78,7 +78,7 @@ function onexit() {
// Usually it is just one event, but it can be more.
assert.ok(ioEvents >= 3, `at least 3 stdout io events, got ${ioEvents}`);
checkInvocations(pipe1, { init: 1, before: 2, after: 2 },
checkInvocations(pipe1, { init: 1, before: 1, after: 1 },
'pipe wrap when sleep.spawn was called');
checkInvocations(pipe2, { init: 1, before: ioEvents, after: ioEvents },
'pipe wrap when sleep.spawn was called');