]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Support -DFAILURE_MODE_TIME=n compiler flag
authorAmos Jeffries <squid3@treenet.co.nz>
Thu, 2 Aug 2012 03:31:52 +0000 (21:31 -0600)
committerAmos Jeffries <squid3@treenet.co.nz>
Thu, 2 Aug 2012 03:31:52 +0000 (21:31 -0600)
This value determins at compile-time how long Squid spends in HIT-only
mode after the failure ratio goes over 1.0. see checkFailureRatio() in
src/client_side_request.cc for details on the ratio.

This flag is supported to remove the need for patching when alteration
is required.

src/client_side_request.cc

index 5a4ac3e24030e4d58d984d2f8446e802d8638439..c7dc229cd023016a423d7cfa50885af2e823f71c 100644 (file)
@@ -199,7 +199,7 @@ ClientHttpRequest::onlyIfCached()const
            request->cache_control->onlyIfCached();
 }
 
-/*
+/**
  * This function is designed to serve a fairly specific purpose.
  * Occasionally our vBNS-connected caches can talk to each other, but not
  * the rest of the world.  Here we try to detect frequent failures which
@@ -211,12 +211,14 @@ ClientHttpRequest::onlyIfCached()const
  *
  * Duane W., Sept 16, 1996
  */
-
-#define FAILURE_MODE_TIME 300
-
 static void
 checkFailureRatio(err_type etype, hier_code hcode)
 {
+    // Can be set at compile time with -D compiler flag
+#ifndef FAILURE_MODE_TIME
+#define FAILURE_MODE_TIME 300
+#endif
+
     static double magic_factor = 100.0;
     double n_good;
     double n_bad;
@@ -251,10 +253,10 @@ checkFailureRatio(err_type etype, hier_code hcode)
     if (request_failure_ratio < 1.0)
         return;
 
-    debugs(33, 0, "Failure Ratio at "<< std::setw(4)<<
+    debugs(33, DBG_CRITICAL, "WARNING: Failure Ratio at "<< std::setw(4)<<
            std::setprecision(3) << request_failure_ratio);
 
-    debugs(33, 0, "Going into hit-only-mode for " <<
+    debugs(33, DBG_CRITICAL, "WARNING: Going into hit-only-mode for " <<
            FAILURE_MODE_TIME / 60 << " minutes...");
 
     hit_only_mode_until = squid_curtime + FAILURE_MODE_TIME;