--------------------- PatchSet 3895 Date: 2006/10/30 18:18:48 Author: rousskov Branch: squid3-icap Tag: (none) Log: - Fixed and simplified up/down status reporting by remembering the last reported status instead of making wrong guesses about it. - Report the reason for the down status. Members: src/ICAP/ICAPServiceRep.cc:1.1.2.9->1.1.2.10 src/ICAP/ICAPServiceRep.h:1.1.2.7->1.1.2.8 Index: squid3/src/ICAP/ICAPServiceRep.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/ICAP/ICAPServiceRep.cc,v retrieving revision 1.1.2.9 retrieving revision 1.1.2.10 diff -u -r1.1.2.9 -r1.1.2.10 --- squid3/src/ICAP/ICAPServiceRep.cc 26 Oct 2006 05:20:12 -0000 1.1.2.9 +++ squid3/src/ICAP/ICAPServiceRep.cc 30 Oct 2006 18:18:48 -0000 1.1.2.10 @@ -20,7 +20,8 @@ theOptions(NULL), theLastUpdate(0), theSessionFailures(0), isSuspended(0), waiting(false), notifying(false), - updateScheduled(false), self(NULL) + updateScheduled(false), self(NULL), + wasAnnouncedUp(true) // do not announce an "up" service at startup {} ICAPServiceRep::~ICAPServiceRep() @@ -164,12 +165,10 @@ void ICAPServiceRep::invalidate() { assert(self != NULL); - const bool wasOk = up(); // ignore unprobed service invalidation - Pointer savedSelf = self; // to prevent destruction when we nullify self self = NULL; - announceStatusChange(wasOk, false); + announceStatusChange("invalidated by reconfigure", false); savedSelf = NULL; // may destroy us and, hence, invalidate cbdata(this) // TODO: it would be nice to invalidate cbdata(this) when not destroyed @@ -193,10 +192,9 @@ if (isSuspended) { debugs(93,4, "keeping ICAPService suspended, also for " << reason); } else { - const bool wasOk = !probed() || up(); isSuspended = reason; - debugs(93,2, "suspending ICAPService for " << reason); - announceStatusChange(wasOk, true); + debugs(93,1, "suspending ICAPService for " << reason); + announceStatusChange("suspended", true); } } @@ -338,8 +336,6 @@ debugs(93,9, "ICAPService changes options from " << theOptions << " to " << newOptions); - const bool wasOk = !probed() || up(); - delete theOptions; theOptions = newOptions; theSessionFailures = 0; @@ -347,7 +343,7 @@ theLastUpdate = squid_curtime; checkOptions(); - announceStatusChange(wasOk, true); + announceStatusChange("down after an options fetch failure", true); } void ICAPServiceRep::checkOptions() @@ -394,15 +390,17 @@ debugs(93, 1, host.buf() << "'s clock is skewed by " << skew << " seconds!"); } -void ICAPServiceRep::announceStatusChange(bool wasOk, bool important) const +void ICAPServiceRep::announceStatusChange(const char *downPhrase, bool important) const { - if (wasOk == up()) // no significant changes to announce + if (wasAnnouncedUp == up()) // no significant changes to announce return; const char *what = bypass ? "optional" : "essential"; - const char *state = wasOk ? "down" : "up"; + const char *state = wasAnnouncedUp ? downPhrase : "up"; const int level = important ? 1 : 2; debugs(93,level, what << " ICAP service is " << state << ": " << uri); + + wasAnnouncedUp = !wasAnnouncedUp; } static Index: squid3/src/ICAP/ICAPServiceRep.h =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/ICAP/ICAPServiceRep.h,v retrieving revision 1.1.2.7 retrieving revision 1.1.2.8 diff -u -r1.1.2.7 -r1.1.2.8 --- squid3/src/ICAP/ICAPServiceRep.h 25 Oct 2006 23:06:15 -0000 1.1.2.7 +++ squid3/src/ICAP/ICAPServiceRep.h 30 Oct 2006 18:18:48 -0000 1.1.2.8 @@ -1,6 +1,6 @@ /* - * $Id: ICAPServiceRep.h,v 1.1.2.7 2006/10/25 23:06:15 rousskov Exp $ + * $Id: ICAPServiceRep.h,v 1.1.2.8 2006/10/30 18:18:48 rousskov Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -156,11 +156,12 @@ void changeOptions(ICAPOptions *newOptions); void checkOptions(); - void announceStatusChange(bool wasUp, bool important) const; + void announceStatusChange(const char *downPhrase, bool important) const; const char *status() const; Pointer self; + mutable bool wasAnnouncedUp; // prevent sequential same-state announcements CBDATA_CLASS2(ICAPServiceRep); };