]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
make checkFailureRatio() work again. Also make 'request_failure_ratio'
authorwessels <>
Tue, 6 Jan 1998 12:12:07 +0000 (12:12 +0000)
committerwessels <>
Tue, 6 Jan 1998 12:12:07 +0000 (12:12 +0000)
global and show its value in the cachemgr info page.

src/client_side.cc
src/errorpage.cc
src/globals.h
src/stat.cc
src/structs.h

index 0ad8b012ed68775faffa53a2f2ac67e0e6c63317..61b263c31870afa03a36d0dcce498ce451ee8baf 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: client_side.cc,v 1.190 1998/01/05 19:53:29 wessels Exp $
+ * $Id: client_side.cc,v 1.191 1998/01/06 05:12:07 wessels Exp $
  *
  * DEBUG: section 33    Client-side Routines
  * AUTHOR: Duane Wessels
@@ -53,9 +53,7 @@ static char *clientConstruct304reply(struct _http_reply *);
 static int CheckQuickAbort2(const clientHttpRequest *);
 static int clientCheckTransferDone(clientHttpRequest *);
 static void CheckQuickAbort(clientHttpRequest *);
-#if CHECK_FAILURE_IS_BROKE
-static void checkFailureRatio(log_type, hier_code);
-#endif
+static void checkFailureRatio(err_type, hier_code);
 static void clientProcessMiss(clientHttpRequest *);
 static void clientAppendReplyHeader(char *, const char *, size_t *, size_t);
 size_t clientBuildReplyHeader(clientHttpRequest *, char *, size_t *, char *, size_t);
@@ -553,9 +551,8 @@ httpRequestFree(void *data)
        redirectUnregister(http->uri, http);
     if (http->acl_checklist)
        aclChecklistFree(http->acl_checklist);
-#if CHECK_FAILURE_IS_BROKE
-    checkFailureRatio(http->log_type, http->al.hier.code);
-#endif
+    if (request)
+        checkFailureRatio(request->err_type, http->al.hier.code);
     safe_free(http->uri);
     safe_free(http->log_uri);
     safe_free(http->al.headers.reply);
@@ -1967,19 +1964,17 @@ clientConstruct304reply(struct _http_reply *source)
  * Duane W., Sept 16, 1996
  */
 
-#if CHECK_FAILURE_IS_BROKE
 static void
-checkFailureRatio(log_type rcode, hier_code hcode)
+checkFailureRatio(err_type etype, hier_code hcode)
 {
-    static double fail_ratio = 0.0;
-    static double magic_factor = 100;
+    static double magic_factor = 100.0;
     double n_good;
     double n_bad;
     if (hcode == HIER_NONE)
        return;
-    n_good = magic_factor / (1.0 + fail_ratio);
+    n_good = magic_factor / (1.0 + request_failure_ratio);
     n_bad = magic_factor - n_good;
-    switch (rcode) {
+    switch (etype) {
     case ERR_DNS_FAIL:
     case ERR_CONNECT_FAIL:
     case ERR_READ_ERROR:
@@ -1988,18 +1983,17 @@ checkFailureRatio(log_type rcode, hier_code hcode)
     default:
        n_good++;
     }
-    fail_ratio = n_bad / n_good;
+    request_failure_ratio = n_bad / n_good;
     if (hit_only_mode_until > squid_curtime)
        return;
-    if (fail_ratio < 1.0)
+    if (request_failure_ratio < 1.0)
        return;
-    debug(12, 0) ("Failure Ratio at %4.2f\n", fail_ratio);
+    debug(12, 0) ("Failure Ratio at %4.2f\n", request_failure_ratio);
     debug(12, 0) ("Going into hit-only-mode for %d minutes...\n",
        FAILURE_MODE_TIME / 60);
     hit_only_mode_until = squid_curtime + FAILURE_MODE_TIME;
-    fail_ratio = 0.8;          /* reset to something less than 1.0 */
+    request_failure_ratio = 0.8;       /* reset to something less than 1.0 */
 }
-#endif
 
 void
 clientHttpConnectionsOpen(void)
index 413e259d1719d94d05c970c72694e1c2f36b6986..3ffa8e2015546b83a952a402b84d03f93fde35a6 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: errorpage.cc,v 1.113 1997/12/27 18:15:05 kostas Exp $
+ * $Id: errorpage.cc,v 1.114 1998/01/06 05:12:08 wessels Exp $
  *
  * DEBUG: section 4     Error Generation
  * AUTHOR: Duane Wessels
@@ -159,6 +159,12 @@ errorSend(int fd, ErrorState * err)
     int len;
     debug(4, 3) ("errorSend: FD %d, err=%p\n", fd, err);
     assert(fd >= 0);
+    /*
+     * ugh, this is how we make sure error codes get back to
+     * the client side for logging and error tracking.
+     */
+    if (err->request)
+       err->request->err_type = err->type;
     buf = errorBuildBuf(err, &len);
     EBIT_SET(err->flags, ERR_FLAG_CBDATA);
     cbdataAdd(err);
index 606bc51a2d969284ce4eba2bfc0bff3b9b98466c..f7ed13d97a39347a2a1e6bf7189e86c400162d96 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: globals.h,v 1.22 1997/12/21 11:21:11 kostas Exp $
+ * $Id: globals.h,v 1.23 1998/01/06 05:12:09 wessels Exp $
  */
 
 extern FILE *debug_log;                /* NULL */
@@ -103,6 +103,7 @@ extern StatCounters Counter;
 extern char *err_type_str[];
 extern char *icp_opcode_str[];
 extern struct radix_node_head *AS_tree_head;
+extern double request_failure_ratio; /* 0.0 */
 
 #ifdef HAVE_SYSLOG
 extern int _db_level;
index 4c02bc687b033f99dd54e42450bd7b437a70380d..ca139e4297d1e5544086a812d032ea506748836f 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: stat.cc,v 1.181 1998/01/05 05:14:16 wessels Exp $
+ * $Id: stat.cc,v 1.182 1998/01/06 05:12:10 wessels Exp $
  *
  * DEBUG: section 18    Cache Manager Statistics
  * AUTHOR: Harvest Derived
@@ -549,6 +549,8 @@ info_get(StoreEntry * sentry)
        Counter.icp.pkts_recv);
     storeAppendPrintf(sentry, "{\tNumber of ICP messages sent:\t%u}\n",
        Counter.icp.pkts_sent);
+    storeAppendPrintf(sentry, "{\tRequest failure ratio:\t%5.2f%%\n",
+       request_failure_ratio);
 
     storeAppendPrintf(sentry, "{\tHTTP requests per minute:\t%.1f}\n",
        Counter.client_http.requests / (runtime / 60.0));
index fa8e6da6b22837f90df4d01cbe166905f9f7714a..96b85ee5ed29b976a44b3708a0615152dc0f5718 100644 (file)
@@ -911,6 +911,7 @@ struct _request_t {
     char *body;
     size_t body_sz;
     struct _HierarchyLogEntry hier;
+    err_type err_type;
 };
 
 struct _cachemgr_passwd {