From 88aad2e576fb23daa47bbb33b23d447e19436b49 Mon Sep 17 00:00:00 2001 From: wessels <> Date: Tue, 6 Jan 1998 12:12:07 +0000 Subject: [PATCH] make checkFailureRatio() work again. Also make 'request_failure_ratio' global and show its value in the cachemgr info page. --- src/client_side.cc | 30 ++++++++++++------------------ src/errorpage.cc | 8 +++++++- src/globals.h | 3 ++- src/stat.cc | 4 +++- src/structs.h | 1 + 5 files changed, 25 insertions(+), 21 deletions(-) diff --git a/src/client_side.cc b/src/client_side.cc index 0ad8b012ed..61b263c318 100644 --- a/src/client_side.cc +++ b/src/client_side.cc @@ -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) diff --git a/src/errorpage.cc b/src/errorpage.cc index 413e259d17..3ffa8e2015 100644 --- a/src/errorpage.cc +++ b/src/errorpage.cc @@ -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); diff --git a/src/globals.h b/src/globals.h index 606bc51a2d..f7ed13d97a 100644 --- a/src/globals.h +++ b/src/globals.h @@ -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; diff --git a/src/stat.cc b/src/stat.cc index 4c02bc687b..ca139e4297 100644 --- a/src/stat.cc +++ b/src/stat.cc @@ -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)); diff --git a/src/structs.h b/src/structs.h index fa8e6da6b2..96b85ee5ed 100644 --- a/src/structs.h +++ b/src/structs.h @@ -911,6 +911,7 @@ struct _request_t { char *body; size_t body_sz; struct _HierarchyLogEntry hier; + err_type err_type; }; struct _cachemgr_passwd { -- 2.47.2