From 72e820efb8128e5249fbc41b4d9e11c1affc06ae Mon Sep 17 00:00:00 2001 From: Amos Jeffries Date: Tue, 2 Oct 2012 14:18:50 +1200 Subject: [PATCH] Bug 3130: helpers are crashing too rapidly 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 | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/helper.cc b/src/helper.cc index c5287607e8..73c4b8855f 100644 --- a/src/helper.cc +++ b/src/helper.cc @@ -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); -- 2.47.3