]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Bug #1168: Forward port of 2.5 patch for handle crashing helpers more gracefully
authorserassio <>
Wed, 22 Dec 2004 22:10:37 +0000 (22:10 +0000)
committerserassio <>
Wed, 22 Dec 2004 22:10:37 +0000 (22:10 +0000)
src/helper.cc
src/structs.h

index 7a60a3047bcb5793a49822dcfaa1a58c3ec51460..1a5e5be3c26b28ac7411c6b70a083318fe56e4bf 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: helper.cc,v 1.63 2004/12/22 15:05:09 serassio Exp $
+ * $Id: helper.cc,v 1.64 2004/12/22 15:10:37 serassio Exp $
  *
  * DEBUG: section 84    Helper process maintenance
  * AUTHOR: Harvest Derived?
@@ -151,6 +151,7 @@ helperOpenServers(helper * hlp)
         comm_read(srv->rfd, srv->rbuf, srv->rbuf_sz - 1, helperHandleRead, srv);
     }
 
+    hlp->last_restart = squid_curtime;
     safe_free(shortname);
     safe_free(procname);
     helperKickQueue(hlp);
@@ -257,6 +258,7 @@ helperStatefulOpenServers(statefulhelper * hlp)
 
     }
 
+    hlp->last_restart = squid_curtime;
     safe_free(shortname);
     safe_free(procname);
     helperStatefulKickQueue(hlp);
@@ -792,8 +794,16 @@ helperServerFree(int fd, void *data)
         debug(84, 0) ("WARNING: %s #%d (FD %d) exited\n",
                       hlp->id_name, srv->index + 1, fd);
 
-        if (hlp->n_active < hlp->n_to_start / 2)
-            fatalf("Too few %s processes are running\n", hlp->id_name);
+        if (hlp->n_active < hlp->n_to_start / 2) {
+            debug(80, 0) ("Too few %s processes are running\n", hlp->id_name);
+
+            if (hlp->last_restart > squid_curtime - 30)
+                fatalf("The %s helpers are crashing too rapidly, need help!\n", hlp->id_name);
+
+            debug(80, 0) ("Starting new helpers\n");
+
+            helperOpenServers(hlp);
+        }
     }
 
     cbdataReferenceDone(srv->parent);
@@ -846,8 +856,16 @@ helperStatefulServerFree(int fd, void *data)
         debug(84, 0) ("WARNING: %s #%d (FD %d) exited\n",
                       hlp->id_name, srv->index + 1, fd);
 
-        if (hlp->n_active < hlp->n_to_start / 2)
-            fatalf("Too few %s processes are running\n", hlp->id_name);
+        if (hlp->n_active <= hlp->n_to_start / 2) {
+            debug(80, 0) ("Too few %s processes are running\n", hlp->id_name);
+
+            if (hlp->last_restart > squid_curtime - 30)
+                fatalf("The %s helpers are crashing too rapidly, need help!\n", hlp->id_name);
+
+            debug(80, 0) ("Starting new helpers\n");
+
+            helperStatefulOpenServers(hlp);
+        }
     }
 
     if (srv->data != NULL)
index b5a19b3e6bf564ceff2f44543d2cb05049416cca..f0c9c197b562c122fef3299de517897ef27424e0 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: structs.h,v 1.500 2004/12/22 14:10:09 serassio Exp $
+ * $Id: structs.h,v 1.501 2004/12/22 15:10:37 serassio Exp $
  *
  *
  * SQUID Web Proxy Cache          http://www.squid-cache.org/
@@ -1896,6 +1896,7 @@ struct _helper
     int ipc_type;
     unsigned int concurrency;
     time_t last_queue_warn;
+    time_t last_restart;
 
     struct
     {
@@ -1922,6 +1923,7 @@ struct _helper_stateful
     HLPSAVAIL *IsAvailable;
     HLPSONEQ *OnEmptyQueue;
     time_t last_queue_warn;
+    time_t last_restart;
 
     struct
     {