Skip to content

Commit d5b3224

Browse files
bnoordhuismhdawson
authored andcommitted
src: backport ignore ENOTCONN on shutdown race
This is a backport of ea37ac0 Original commit message: On AIX, OS X and the BSDs, calling shutdown() on one end of a pipe when the other end has closed the connection fails with ENOTCONN. The sequential/test-child-process-execsync test failed sporadically because of a race between the parent and the child where one closed its end of the pipe before the other got around to calling shutdown() on its end of the pipe. Libuv is not the right place to handle that because it can't tell if the ENOTCONN error is genuine but io.js can. Refs: libuv/libuv#268 PR-URL: iojs#1214 Reviewed-By: Bert Belder <[email protected]> Fixes: nodejs/node-v0.x-archive#9444. Reviewed-By: Julien Gilli <[email protected]> PR-URL: nodejs/node-v0.x-archive#14480
1 parent 4e154d6 commit d5b3224

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/spawn_sync.cc

+8
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,14 @@ void SyncProcessStdioPipe::WriteCallback(uv_write_t* req, int result) {
342342
void SyncProcessStdioPipe::ShutdownCallback(uv_shutdown_t* req, int result) {
343343
SyncProcessStdioPipe* self =
344344
reinterpret_cast<SyncProcessStdioPipe*>(req->handle->data);
345+
346+
// On AIX, OS X and the BSDs, calling shutdown() on one end of a pipe
347+
// when the other end has closed the connection fails with ENOTCONN.
348+
// Libuv is not the right place to handle that because it can't tell
349+
// if the error is genuine but we here can.
350+
if (result == UV_ENOTCONN)
351+
result = 0;
352+
345353
self->OnShutdownDone(result);
346354
}
347355

0 commit comments

Comments
 (0)