summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Noordhuis <info@bnoordhuis.nl>2015-03-19 23:33:52 +0100
committerMichael Dawson <Michael_Dawson@ca.ibm.com>2015-04-13 15:18:03 -0700
commitd5b32246fbbc231178e6e6d3ca0d14ba1b09b5d6 (patch)
tree0649579205e35f205f4c457e199c41c6cfb9789c
parent4e154d6ef8b60808e2c8691926f802f5f0f433b4 (diff)
downloadnode-new-d5b32246fbbc231178e6e6d3ca0d14ba1b09b5d6.tar.gz
src: backport ignore ENOTCONN on shutdown race
This is a backport of ea37ac04f4e4e9248fb361d65a3cd69f57bcaba1 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 <bertbelder@gmail.com> Fixes: https://github.com/joyent/node/issues/9444. Reviewed-By: Julien Gilli <julien.gilli@joyent.com> PR-URL: https://github.com/joyent/node/pull/14480
-rw-r--r--src/spawn_sync.cc8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/spawn_sync.cc b/src/spawn_sync.cc
index f13a9e9ed3..4f1a26c907 100644
--- a/src/spawn_sync.cc
+++ b/src/spawn_sync.cc
@@ -342,6 +342,14 @@ void SyncProcessStdioPipe::WriteCallback(uv_write_t* req, int result) {
void SyncProcessStdioPipe::ShutdownCallback(uv_shutdown_t* req, int result) {
SyncProcessStdioPipe* self =
reinterpret_cast<SyncProcessStdioPipe*>(req->handle->data);
+
+ // 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.
+ // Libuv is not the right place to handle that because it can't tell
+ // if the error is genuine but we here can.
+ if (result == UV_ENOTCONN)
+ result = 0;
+
self->OnShutdownDone(result);
}