From: Amos Jeffries Date: Sat, 9 Oct 2010 12:29:51 +0000 (+1300) Subject: Close earlier opened pipes when any IPC open fails X-Git-Tag: take08~55^2~124^2~38 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bd1160684ee25c5766bb82bc9e421be46afbd584;p=thirdparty%2Fsquid.git Close earlier opened pipes when any IPC open fails --- diff --git a/src/ipc.cc b/src/ipc.cc index 5ecc9e2145..f346c9a5cd 100644 --- a/src/ipc.cc +++ b/src/ipc.cc @@ -129,18 +129,18 @@ ipcCreate(int type, const char *prog, const char *const args[], const char *name if (pipe(p2c) < 0) { debugs(54, 0, "ipcCreate: pipe: " << xstrerror()); - return -1; + return -1; // maybe ipcCloseAllFD(prfd, pwfd, crfd, cwfd); } + fd_open(prfd = p2c[0], FD_PIPE, "IPC FIFO Parent Read"); + fd_open(cwfd = p2c[1], FD_PIPE, "IPC FIFO Child Write"); if (pipe(c2p) < 0) { debugs(54, 0, "ipcCreate: pipe: " << xstrerror()); - return -1; + return ipcCloseAllFD(prfd, pwfd, crfd, cwfd); } - - fd_open(prfd = p2c[0], FD_PIPE, "IPC FIFO Parent Read"); - fd_open(cwfd = p2c[1], FD_PIPE, "IPC FIFO Child Write"); fd_open(crfd = c2p[0], FD_PIPE, "IPC FIFO Child Read"); fd_open(pwfd = c2p[1], FD_PIPE, "IPC FIFO Parent Write"); + #if HAVE_SOCKETPAIR && defined(AF_UNIX) } else if (type == IPC_UNIX_STREAM) {