]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Fix closePipesSafely. It is a 3.2 feature
authorAmos Jeffries <squid3@treenet.co.nz>
Fri, 16 Mar 2012 05:21:37 +0000 (23:21 -0600)
committerAmos Jeffries <squid3@treenet.co.nz>
Fri, 16 Mar 2012 05:21:37 +0000 (23:21 -0600)
src/helper.cc

index 9165908fcae420bd93ea3da788f7f7e845ca46ae..4f6949d16d7b1f5f70c66cbfe53d4ae20456077b 100644 (file)
@@ -1,3 +1,4 @@
+
 /*
  * $Id$
  *
@@ -974,7 +975,25 @@ helperHandleRead(int fd, char *buf, size_t len, comm_err_t flag, int xerrno, voi
                    "helper that overflowed " << srv->rbuf_sz << "-byte " <<
                    "Squid input buffer: " << hlp->id_name << " #" <<
                    (srv->index + 1));
-            srv->closePipesSafely();
+
+            int wfd = srv->wfd;
+            srv->wfd = -1;
+            if (srv->rfd == wfd)
+                srv->rfd = -1;
+            srv->flags.closing=1;
+            comm_close(wfd);
+
+#if _SQUID_MSWIN_
+            if (srv->hIpc) {
+                if (WaitForSingleObject(srv->hIpc, 5000) != WAIT_OBJECT_0) {
+                    getCurrentTime();
+                    debugs(84, 1, "helperShutdown: WARNING: " << hlp->id_name <<
+                           " #" << no << " (" << hlp->cmdline->key << "," <<
+                           (long int)srv->pid << ") didn't exit in 5 seconds");
+                }
+                CloseHandle(srv->hIpc);
+            }
+#endif
             return;
         }
 
@@ -1073,7 +1092,24 @@ helperStatefulHandleRead(int fd, char *buf, size_t len, comm_err_t flag, int xer
                    "helper that overflowed " << srv->rbuf_sz << "-byte " <<
                    "Squid input buffer: " << hlp->id_name << " #" <<
                    (srv->index + 1));
-            srv->closePipesSafely();
+            int wfd = srv->wfd;
+            srv->wfd = -1;
+            if (srv->rfd == wfd)
+                srv->rfd = -1;
+            srv->flags.closing=1;
+            comm_close(wfd);
+
+#if _SQUID_MSWIN_
+            if (srv->hIpc) {
+                if (WaitForSingleObject(srv->hIpc, 5000) != WAIT_OBJECT_0) {
+                    getCurrentTime();
+                    debugs(84, 1, "helperShutdown: WARNING: " << hlp->id_name <<
+                           " #" << no << " (" << hlp->cmdline->key << "," <<
+                           (long int)srv->pid << ") didn't exit in 5 seconds");
+                }
+                CloseHandle(srv->hIpc);
+            }
+#endif
             return;
         }