]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Bug 3130: helpers are crashing too rapidly
authorAmos Jeffries <squid3@treenet.co.nz>
Tue, 2 Oct 2012 02:18:50 +0000 (14:18 +1200)
committerAmos Jeffries <squid3@treenet.co.nz>
Tue, 2 Oct 2012 02:18:50 +0000 (14:18 +1200)
As discussed quite many months ago. This reduces the FATAL when helpers
crash/exit to a critical level ERROR have responded with useful reply to
at least one lookup.

The result is that Squid can now cope with helpers written in languages
which cannot loop infinitely. For example; PHP helpers often exit after
a timeout, broken scripts written to respond and exit immediately,
and helpers which encounter some permissions error and respond only with
"ERR" or "BH" results before aborting.

src/helper.cc

index c5287607e831d3c3c96b0ed822741fa4b1262f6b..73c4b8855f0cc137a4eb03011918c1671bee3bb8 100644 (file)
@@ -738,8 +738,12 @@ helperServerFree(helper_server *srv)
         if (hlp->childs.needNew() > 0) {
             debugs(80, DBG_IMPORTANT, "Too few " << hlp->id_name << " processes are running (need " << hlp->childs.needNew() << "/" << hlp->childs.n_max << ")");
 
-            if (hlp->childs.n_active < hlp->childs.n_startup && hlp->last_restart > squid_curtime - 30)
-                fatalf("The %s helpers are crashing too rapidly, need help!\n", hlp->id_name);
+            if (hlp->childs.n_active < hlp->childs.n_startup && hlp->last_restart > squid_curtime - 30) {
+                if (srv->stats.replies < 1)
+                    fatalf("The %s helpers are crashing too rapidly, need help!\n", hlp->id_name);
+                else
+                    debugs(80, DBG_CRITICAL, "ERROR: The " << hlp->id_name << " helpers are crashing too rapidly, need help!");
+            }
 
             debugs(80, DBG_IMPORTANT, "Starting new helpers");
             helperOpenServers(hlp);
@@ -799,8 +803,12 @@ helperStatefulServerFree(helper_stateful_server *srv)
         if (hlp->childs.needNew() > 0) {
             debugs(80, DBG_IMPORTANT, "Too few " << hlp->id_name << " processes are running (need " << hlp->childs.needNew() << "/" << hlp->childs.n_max << ")");
 
-            if (hlp->childs.n_active < hlp->childs.n_startup && hlp->last_restart > squid_curtime - 30)
-                fatalf("The %s helpers are crashing too rapidly, need help!\n", hlp->id_name);
+            if (hlp->childs.n_active < hlp->childs.n_startup && hlp->last_restart > squid_curtime - 30) {
+                if (srv->stats.replies < 1)
+                    fatalf("The %s helpers are crashing too rapidly, need help!\n", hlp->id_name);
+                else
+                    debugs(80, DBG_CRITICAL, "ERROR: The " << hlp->id_name << " helpers are crashing too rapidly, need help!");
+            }
 
             debugs(80, DBG_IMPORTANT, "Starting new helpers");
             helperStatefulOpenServers(hlp);