--------------------- PatchSet 6988 Date: 2008/02/23 10:31:18 Author: chtsanti Branch: async-calls Tag: (none) Log: - Add TheAssertsPerStep counter to count the number of assertions per single main loop iteration. This counter is reset to zero at the beginning of every main loop iteration. - To reset the TheAssertsPerStep counter a new AsyncEngine based class used, the XAssertsEngine. - Add "assert_burst_max " to squid.conf. If TheAssertsPerStep counter exceeds a non-negative assert_burst_max, we abort(). If set to zero, the first assertion aborts Squid, giving users the old behavior. If set to a negative number, there is no limit. Members: src/Debug.h:1.10.4.3->1.10.4.4 src/cf.data.pre:1.155.4.3->1.155.4.4 src/debug.cc:1.18.4.4->1.18.4.5 src/main.cc:1.89.4.7->1.89.4.8 src/structs.h:1.116.4.3->1.116.4.4 Index: squid3/src/Debug.h =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/Debug.h,v retrieving revision 1.10.4.3 retrieving revision 1.10.4.4 diff -u -r1.10.4.3 -r1.10.4.4 --- squid3/src/Debug.h 14 Feb 2008 21:46:38 -0000 1.10.4.3 +++ squid3/src/Debug.h 23 Feb 2008 10:31:18 -0000 1.10.4.4 @@ -1,5 +1,5 @@ /* - * $Id: Debug.h,v 1.10.4.3 2008/02/14 21:46:38 chtsanti Exp $ + * $Id: Debug.h,v 1.10.4.4 2008/02/23 10:31:18 chtsanti Exp $ * * DEBUG: section 0 Debug Routines * AUTHOR: Harvest Derived @@ -54,6 +54,8 @@ void WillCatchException(int debug_section, int debug_level, const char *who); void WontCatchException(); +extern int TheSalvagedAsserts; +extern int TheAssertsPerStep; /* defined names for Debug Levels */ #define DBG_CRITICAL 0 /**< critical messages always shown when they occur */ Index: squid3/src/cf.data.pre =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/cf.data.pre,v retrieving revision 1.155.4.3 retrieving revision 1.155.4.4 diff -u -r1.155.4.3 -r1.155.4.4 --- squid3/src/cf.data.pre 12 Feb 2008 19:04:39 -0000 1.155.4.3 +++ squid3/src/cf.data.pre 23 Feb 2008 10:31:18 -0000 1.155.4.4 @@ -1,6 +1,6 @@ # -# $Id: cf.data.pre,v 1.155.4.3 2008/02/12 19:04:39 rousskov Exp $ +# $Id: cf.data.pre,v 1.155.4.4 2008/02/23 10:31:18 chtsanti Exp $ # # SQUID Web Proxy Cache http://www.squid-cache.org/ # ---------------------------------------------------------- @@ -5609,4 +5609,20 @@ rounded to 1000. DOC_END +NAME: assert_burst_max +TYPE: int +LOC: Config.assert_burst_max +DEFAULT: 100 +DOC_START + When this is set to a possitive number then Squid will abort + if an assertions burst exceeds this number. + If set to zero, the first assertion aborts Squid, giving users + the old behavior. If set to a negative number, there is no + limit. + An asssertions burst defined as the number of assertions per + single Squid main loop iteration. + WARNING! This is an experimental feature and the definition + of a "burst" can change +DOC_END + EOF Index: squid3/src/debug.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/debug.cc,v retrieving revision 1.18.4.4 retrieving revision 1.18.4.5 diff -u -r1.18.4.4 -r1.18.4.5 --- squid3/src/debug.cc 16 Feb 2008 21:06:42 -0000 1.18.4.4 +++ squid3/src/debug.cc 23 Feb 2008 10:31:18 -0000 1.18.4.5 @@ -1,5 +1,5 @@ /* - * $Id: debug.cc,v 1.18.4.4 2008/02/16 21:06:42 chtsanti Exp $ + * $Id: debug.cc,v 1.18.4.5 2008/02/23 10:31:18 chtsanti Exp $ * * DEBUG: section 0 Debug Routines * AUTHOR: Harvest Derived @@ -44,6 +44,7 @@ static bool AsyncCall_Handling_Exceptions = 0; int TheCascadingAsserts = 0; int TheSalvagedAsserts = 0; +int TheAssertsPerStep = 0; static char *debug_log_file = NULL; static int Ctx_Lock = 0; @@ -590,18 +591,30 @@ void xassert(const char *msg, const char *file, int line) { - if (TheCascadingAsserts < MAX_CASCADING_ASSERTS && AsyncCall_Handling_Exceptions) { + debugs(0, 0, "assertion failed: " << file << ":" << line << ": \"" << msg << "\""); + + if (AsyncCall_Handling_Exceptions && + TheCascadingAsserts < MAX_CASCADING_ASSERTS && + ( Config.assert_burst_max < 0 || + (Config.assert_burst_max > 0 && TheAssertsPerStep < Config.assert_burst_max) + ) + ) { TheCascadingAsserts++; TheSalvagedAsserts++; - debugs(0, 0, "assertion failed: " << file << ":" << line << ": \"" << msg << "\". Trying to survive. Salvaged assertions: " << TheSalvagedAsserts); + TheAssertsPerStep++; + + debugs(0, 0, "salvaging assertion #" << TheSalvagedAsserts << " (" << + TheAssertsPerStep << "/" << Config.assert_burst_max << ")"); throw TextException(msg, file, line); } - debugs(0, 0, "assertion failed: " << file << ":" << line << ": \"" << msg << "\""); if(TheCascadingAsserts >= MAX_CASCADING_ASSERTS) - debugs(0, 0, "I am dying after " << TheCascadingAsserts << "cascading assertions!" ); + debugs(0, 0, "dying after " << TheCascadingAsserts << "cascading assertions" ); + + if(Config.assert_burst_max > 0 && TheAssertsPerStep >= Config.assert_burst_max) + debugs(0, 0, "dying after an " << TheAssertsPerStep << " assertions burst" ); if (!shutting_down) abort(); Index: squid3/src/main.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/main.cc,v retrieving revision 1.89.4.7 retrieving revision 1.89.4.8 diff -u -r1.89.4.7 -r1.89.4.8 --- squid3/src/main.cc 12 Feb 2008 19:05:00 -0000 1.89.4.7 +++ squid3/src/main.cc 23 Feb 2008 10:31:18 -0000 1.89.4.8 @@ -1,6 +1,6 @@ /* - * $Id: main.cc,v 1.89.4.7 2008/02/12 19:05:00 rousskov Exp $ + * $Id: main.cc,v 1.89.4.8 2008/02/23 10:31:18 chtsanti Exp $ * * DEBUG: section 1 Startup and Main Loop * AUTHOR: Harvest Derived @@ -143,6 +143,17 @@ }; }; +class XAssertsEngine : public AsyncEngine +{ + +public: + int checkEvents(int timeout) + { + TheAssertsPerStep = 0; + return EVENT_IDLE; + }; +}; + class SignalEngine: public AsyncEngine { @@ -1296,6 +1307,9 @@ mainLoop.registerEngine(&signalEngine); + XAssertsEngine xassertsEngine; + mainLoop.registerEngine(&xassertsEngine); + /* TODO: stop requiring the singleton here */ mainLoop.registerEngine(EventScheduler::GetInstance()); Index: squid3/src/structs.h =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/structs.h,v retrieving revision 1.116.4.3 retrieving revision 1.116.4.4 diff -u -r1.116.4.3 -r1.116.4.4 --- squid3/src/structs.h 12 Feb 2008 19:05:14 -0000 1.116.4.3 +++ squid3/src/structs.h 23 Feb 2008 10:31:18 -0000 1.116.4.4 @@ -1,6 +1,6 @@ /* - * $Id: structs.h,v 1.116.4.3 2008/02/12 19:05:14 rousskov Exp $ + * $Id: structs.h,v 1.116.4.4 2008/02/23 10:31:18 chtsanti Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -692,6 +692,7 @@ #endif char *accept_filter; + int assert_burst_max; }; struct _SquidConfig2