]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Close earlier opened pipes when any IPC open fails
authorAmos Jeffries <squid3@treenet.co.nz>
Sat, 9 Oct 2010 12:29:51 +0000 (01:29 +1300)
committerAmos Jeffries <squid3@treenet.co.nz>
Sat, 9 Oct 2010 12:29:51 +0000 (01:29 +1300)
src/ipc.cc

index 5ecc9e2145dab1cc2b331b8fd94f085d5e655f9b..f346c9a5cd87e0034c2578ef7c9a0a0cb77f7cad 100644 (file)
@@ -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) {