From: serassio <> Date: Wed, 22 Dec 2004 22:10:37 +0000 (+0000) Subject: Bug #1168: Forward port of 2.5 patch for handle crashing helpers more gracefully X-Git-Tag: SQUID_3_0_PRE4~950 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=5ea33fce1749c26148150d7f0d0959334c6b91ba;p=thirdparty%2Fsquid.git Bug #1168: Forward port of 2.5 patch for handle crashing helpers more gracefully --- diff --git a/src/helper.cc b/src/helper.cc index 7a60a3047b..1a5e5be3c2 100644 --- a/src/helper.cc +++ b/src/helper.cc @@ -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) diff --git a/src/structs.h b/src/structs.h index b5a19b3e6b..f0c9c197b5 100644 --- a/src/structs.h +++ b/src/structs.h @@ -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 {