From: wessels <> Date: Tue, 21 Jul 1998 02:20:50 +0000 (+0000) Subject: Fixed cachemgr 'objects' implementation. dump one bucket per call, use X-Git-Tag: SQUID_3_0_PRE1~3037 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=1da3b90b08c3c15056862c162d0cddda7ea6f307;p=thirdparty%2Fsquid.git Fixed cachemgr 'objects' implementation. dump one bucket per call, use events to process one bucket at a time --- diff --git a/src/HttpHeader.cc b/src/HttpHeader.cc index 6aac17edb2..26087ef9ef 100644 --- a/src/HttpHeader.cc +++ b/src/HttpHeader.cc @@ -1,6 +1,6 @@ /* - * $Id: HttpHeader.cc,v 1.49 1998/07/20 17:19:05 wessels Exp $ + * $Id: HttpHeader.cc,v 1.50 1998/07/20 20:20:50 wessels Exp $ * * DEBUG: section 55 HTTP Header * AUTHOR: Alex Rousskov @@ -244,7 +244,7 @@ httpHeaderInitModule() httpHdrCcInitModule(); /* register with cache manager */ cachemgrRegister("http_headers", - "HTTP Header Statistics", httpHeaderStoreReport, 0); + "HTTP Header Statistics", httpHeaderStoreReport, 0, 1); } void diff --git a/src/access_log.cc b/src/access_log.cc index 88c3e97a32..d95aaab52b 100644 --- a/src/access_log.cc +++ b/src/access_log.cc @@ -1,7 +1,7 @@ /* - * $Id: access_log.cc,v 1.36 1998/07/20 17:19:14 wessels Exp $ + * $Id: access_log.cc,v 1.37 1998/07/20 20:20:51 wessels Exp $ * * DEBUG: section 46 Access Log * AUTHOR: Duane Wessels @@ -354,7 +354,7 @@ fvdbInit(void) forw_table = hash_create((HASHCMP *) strcmp, 977, hash4); cachemgrRegister("via_headers", "Via Request Headers", fvdbDumpVia, 0); cachemgrRegister("forw_headers", "X-Forwarded-For Request Headers", - fvdbDumpForw, 0); + fvdbDumpForw, 0, 1); } static void diff --git a/src/cache_cf.cc b/src/cache_cf.cc index ef047d03f1..fe538e35dc 100644 --- a/src/cache_cf.cc +++ b/src/cache_cf.cc @@ -1,6 +1,6 @@ /* - * $Id: cache_cf.cc,v 1.289 1998/07/20 17:19:20 wessels Exp $ + * $Id: cache_cf.cc,v 1.290 1998/07/20 20:20:52 wessels Exp $ * * DEBUG: section 3 Configuration File Parsing * AUTHOR: Harvest Derived @@ -198,7 +198,7 @@ parseConfigFile(const char *file_name) cachemgrRegister("config", "Current Squid Configuration", dump_config, - 1); + 1, 1); return 0; } diff --git a/src/cache_manager.cc b/src/cache_manager.cc index b02ac4050c..53741f19a0 100644 --- a/src/cache_manager.cc +++ b/src/cache_manager.cc @@ -1,6 +1,6 @@ /* - * $Id: cache_manager.cc,v 1.14 1998/07/20 19:25:30 wessels Exp $ + * $Id: cache_manager.cc,v 1.15 1998/07/20 20:20:53 wessels Exp $ * * DEBUG: section 16 Cache Manager Objects * AUTHOR: Duane Wessels @@ -44,7 +44,10 @@ typedef struct _action_table { char *action; char *desc; OBJH *handler; - int pw_req_flag; + struct { + int pw_req:1; + int atomic:1; + } flags; struct _action_table *next; } action_table; @@ -61,7 +64,7 @@ static OBJH cachemgrMenu; action_table *ActionTable = NULL; void -cachemgrRegister(const char *action, const char *desc, OBJH * handler, int pw_req_flag) +cachemgrRegister(const char *action, const char *desc, OBJH * handler, int pw_req_flag, int atomic) { action_table *a; action_table **A; @@ -73,7 +76,8 @@ cachemgrRegister(const char *action, const char *desc, OBJH * handler, int pw_re a->action = xstrdup(action); a->desc = xstrdup(desc); a->handler = handler; - a->pw_req_flag = pw_req_flag; + a->flags.pw_req = pw_req_flag; + a->flags.atomic = atomic; for (A = &ActionTable; *A; A = &(*A)->next); *A = a; debug(16, 3) ("cachemgrRegister: registered %s\n", action); @@ -154,7 +158,7 @@ cachemgrCheckPassword(cachemgrStateData * mgr) action_table *a = cachemgrFindAction(mgr->action); assert(a != NULL); if (pwd == NULL) - return a->pw_req_flag; + return a->flags.pw_req; if (strcmp(pwd, "disable") == 0) return 1; if (strcmp(pwd, "none") == 0) @@ -233,7 +237,8 @@ cachemgrStart(int fd, request_t * request, StoreEntry * entry) /* retrieve object requested */ a = cachemgrFindAction(mgr->action); assert(a != NULL); - storeBuffer(entry); + if (a->flags.atomic) + storeBuffer(entry); { HttpReply *rep = entry->mem_obj->reply; /* prove there are no previous reply headers around */ @@ -249,8 +254,10 @@ cachemgrStart(int fd, request_t * request, StoreEntry * entry) httpReplySwapOut(rep, entry); } a->handler(entry); - storeBufferFlush(entry); - storeComplete(entry); + if (a->flags.atomic) { + storeBufferFlush(entry); + storeComplete(entry); + } cachemgrStateFree(mgr); } @@ -268,7 +275,7 @@ cachemgrActionProtection(const action_table * at) assert(at); pwd = cachemgrPasswdGet(Config.passwd_list, at->action); if (!pwd) - return at->pw_req_flag ? "hidden" : "public"; + return at->flags.pw_req ? "hidden" : "public"; if (!strcmp(pwd, "disable")) return "disabled"; if (strcmp(pwd, "none") == 0) @@ -307,8 +314,8 @@ cachemgrInit(void) { cachemgrRegister("menu", "This Cachemanager Menu", - cachemgrMenu, 0); + cachemgrMenu, 0, 1); cachemgrRegister("shutdown", "Shut Down the Squid Process", - cachemgrShutdown, 1); + cachemgrShutdown, 1, 1); } diff --git a/src/cbdata.cc b/src/cbdata.cc index b4f325b1ed..162eb5f408 100644 --- a/src/cbdata.cc +++ b/src/cbdata.cc @@ -1,6 +1,6 @@ /* - * $Id: cbdata.cc,v 1.22 1998/07/20 17:19:24 wessels Exp $ + * $Id: cbdata.cc,v 1.23 1998/07/20 20:20:54 wessels Exp $ * * DEBUG: section 45 Callback Data Registry * AUTHOR: Duane Wessels @@ -102,7 +102,7 @@ cbdataInit(void) htable = hash_create(cbdata_cmp, 1 << 8, cbdata_hash); cachemgrRegister("cbdata", "Callback Data Registry Contents", - cbdataDump, 0); + cbdataDump, 0, 1); } void diff --git a/src/client_db.cc b/src/client_db.cc index 1afe07514d..aa77b5c034 100644 --- a/src/client_db.cc +++ b/src/client_db.cc @@ -1,6 +1,6 @@ /* - * $Id: client_db.cc,v 1.36 1998/07/20 17:19:27 wessels Exp $ + * $Id: client_db.cc,v 1.37 1998/07/20 20:20:55 wessels Exp $ * * DEBUG: section 0 Client Database * AUTHOR: Duane Wessels @@ -56,7 +56,7 @@ clientdbInit(void) cachemgrRegister("client_list", "Cache Client List", clientdbDump, - 0); + 0, 1); } void diff --git a/src/comm.cc b/src/comm.cc index ce310f306b..7ef441d08a 100644 --- a/src/comm.cc +++ b/src/comm.cc @@ -1,7 +1,7 @@ /* - * $Id: comm.cc,v 1.274 1998/07/20 17:19:30 wessels Exp $ + * $Id: comm.cc,v 1.275 1998/07/20 20:20:56 wessels Exp $ * * DEBUG: section 5 Socket Functions * AUTHOR: Harvest Derived @@ -1214,7 +1214,7 @@ comm_init(void) invert32[i] = (int) (32.0 / (double) i + 0.5); cachemgrRegister("comm_incoming", "comm_incoming() stats", - commIncomingStats, 0); + commIncomingStats, 0, 1); } diff --git a/src/dns.cc b/src/dns.cc index b07aad8164..b700adc2fb 100644 --- a/src/dns.cc +++ b/src/dns.cc @@ -1,6 +1,6 @@ /* - * $Id: dns.cc,v 1.59 1998/07/20 17:19:33 wessels Exp $ + * $Id: dns.cc,v 1.60 1998/07/20 20:20:57 wessels Exp $ * * DEBUG: section 34 Dnsserver interface * AUTHOR: Harvest Derived @@ -215,7 +215,7 @@ dnsOpenServers(void) if (NDnsServersAlloc == 0 && Config.dnsChildren > 0) fatal("Failed to start any dnsservers"); cachemgrRegister("dns", "dnsserver child process information", - dnsStats, 0); + dnsStats, 0, 1); debug(34, 1) ("Started %d 'dnsserver' processes\n", NDnsServersAlloc); } diff --git a/src/event.cc b/src/event.cc index 579863955e..7e108f4c91 100644 --- a/src/event.cc +++ b/src/event.cc @@ -1,6 +1,6 @@ /* - * $Id: event.cc,v 1.20 1998/07/20 17:19:36 wessels Exp $ + * $Id: event.cc,v 1.21 1998/07/20 20:20:58 wessels Exp $ * * DEBUG: section 41 Event Processing * AUTHOR: Henrik Nordstrom @@ -154,7 +154,7 @@ eventInit(void) { cachemgrRegister("events", "Event Queue", - eventDump, 0); + eventDump, 0, 1); } static void diff --git a/src/fqdncache.cc b/src/fqdncache.cc index 8b4d7c9e1f..59b32d7adc 100644 --- a/src/fqdncache.cc +++ b/src/fqdncache.cc @@ -1,7 +1,7 @@ /* - * $Id: fqdncache.cc,v 1.106 1998/07/20 17:19:40 wessels Exp $ + * $Id: fqdncache.cc,v 1.107 1998/07/20 20:20:59 wessels Exp $ * * DEBUG: section 35 FQDN Cache * AUTHOR: Harvest Derived @@ -610,7 +610,7 @@ fqdncache_init(void) fqdn_table = hash_create(urlcmp, n, hash4); cachemgrRegister("fqdncache", "FQDN Cache Stats and Contents", - fqdnStats, 0); + fqdnStats, 0, 1); } /* clean up the pending entries in dnsserver */ diff --git a/src/ipcache.cc b/src/ipcache.cc index 3aa6c5404d..84c6676f02 100644 --- a/src/ipcache.cc +++ b/src/ipcache.cc @@ -1,6 +1,6 @@ /* - * $Id: ipcache.cc,v 1.192 1998/07/20 17:19:49 wessels Exp $ + * $Id: ipcache.cc,v 1.193 1998/07/20 20:21:00 wessels Exp $ * * DEBUG: section 14 IP Cache * AUTHOR: Harvest Derived @@ -678,7 +678,7 @@ ipcache_init(void) ip_table = hash_create(urlcmp, n, hash4); cachemgrRegister("ipcache", "IP Cache Stats and Contents", - stat_ipcache_get, 0); + stat_ipcache_get, 0, 1); } int diff --git a/src/mem.cc b/src/mem.cc index d57781df5b..08d13ba7ab 100644 --- a/src/mem.cc +++ b/src/mem.cc @@ -1,6 +1,6 @@ /* - * $Id: mem.cc,v 1.28 1998/07/20 17:19:52 wessels Exp $ + * $Id: mem.cc,v 1.29 1998/07/20 20:21:02 wessels Exp $ * * DEBUG: section 13 High Level Memory Pool Management * AUTHOR: Harvest Derived @@ -288,7 +288,7 @@ memInit(void) } cachemgrRegister("mem", "Memory Utilization", - memStats, 0); + memStats, 0, 1); } void diff --git a/src/neighbors.cc b/src/neighbors.cc index f7362fd139..8423a23f62 100644 --- a/src/neighbors.cc +++ b/src/neighbors.cc @@ -1,6 +1,6 @@ /* - * $Id: neighbors.cc,v 1.226 1998/07/20 17:19:55 wessels Exp $ + * $Id: neighbors.cc,v 1.227 1998/07/20 20:21:04 wessels Exp $ * * DEBUG: section 15 Neighbor Routines * AUTHOR: Harvest Derived @@ -395,10 +395,10 @@ neighbors_open(int fd) first_ping = Config.peers; cachemgrRegister("server_list", "Peer Cache Statistics", - neighborDumpPeers, 0); + neighborDumpPeers, 0, 1); cachemgrRegister("non_peers", "List of Unknown sites sending ICP messages", - neighborDumpNonPeers, 0); + neighborDumpNonPeers, 0, 1); } int diff --git a/src/net_db.cc b/src/net_db.cc index 6b400b3f73..cf0e2598e8 100644 --- a/src/net_db.cc +++ b/src/net_db.cc @@ -1,6 +1,6 @@ /* - * $Id: net_db.cc,v 1.118 1998/07/20 19:25:36 wessels Exp $ + * $Id: net_db.cc,v 1.119 1998/07/20 20:21:05 wessels Exp $ * * DEBUG: section 37 Network Measurement Database * AUTHOR: Duane Wessels @@ -634,7 +634,7 @@ netdbInit(void) netdbReloadState(); cachemgrRegister("netdb", "Network Measurement Database", - netdbDump, 0); + netdbDump, 0, 1); #endif } diff --git a/src/pconn.cc b/src/pconn.cc index f908475502..921b9fcaca 100644 --- a/src/pconn.cc +++ b/src/pconn.cc @@ -1,6 +1,6 @@ /* - * $Id: pconn.cc,v 1.17 1998/07/20 17:19:57 wessels Exp $ + * $Id: pconn.cc,v 1.18 1998/07/20 20:21:06 wessels Exp $ * * DEBUG: section 48 Persistent Connections * AUTHOR: Duane Wessels @@ -163,7 +163,7 @@ pconnInit(void) } cachemgrRegister("pconn", "Persistent Connection Utilization Histograms", - pconnHistDump, 0); + pconnHistDump, 0, 1); debug(48, 3) ("persistent connection module initialized\n"); } diff --git a/src/protos.h b/src/protos.h index fe1e712537..3a863e584c 100644 --- a/src/protos.h +++ b/src/protos.h @@ -576,7 +576,7 @@ extern void netdbExchangeUpdatePeer(struct in_addr, peer *, double, double); extern peer *netdbClosestParent(request_t *); extern void cachemgrStart(int fd, request_t * request, StoreEntry * entry); -extern void cachemgrRegister(const char *, const char *, OBJH *, int); +extern void cachemgrRegister(const char *, const char *, OBJH *, int, int); extern void cachemgrInit(void); extern void peerSelect(request_t *, StoreEntry *, PSC *, PSC *, void *data); diff --git a/src/redirect.cc b/src/redirect.cc index 25753e70fa..c79001b10d 100644 --- a/src/redirect.cc +++ b/src/redirect.cc @@ -1,6 +1,6 @@ /* - * $Id: redirect.cc,v 1.61 1998/07/20 17:20:02 wessels Exp $ + * $Id: redirect.cc,v 1.62 1998/07/20 20:21:08 wessels Exp $ * * DEBUG: section 29 Redirector * AUTHOR: Duane Wessels @@ -359,7 +359,7 @@ redirectOpenServers(void) memset(&RedirectStats, '\0', sizeof(RedirectStats)); cachemgrRegister("redirector", "URL Redirector Stats", - redirectStats, 0); + redirectStats, 0, 1); } safe_free(short_prg); safe_free(short_prg2); diff --git a/src/stat.cc b/src/stat.cc index f9671415cc..4604b12f8a 100644 --- a/src/stat.cc +++ b/src/stat.cc @@ -1,6 +1,6 @@ /* - * $Id: stat.cc,v 1.261 1998/07/20 17:20:10 wessels Exp $ + * $Id: stat.cc,v 1.262 1998/07/20 20:21:09 wessels Exp $ * * DEBUG: section 18 Cache Manager Statistics * AUTHOR: Harvest Derived @@ -109,6 +109,13 @@ #define DEBUG_OPENFD 1 +typedef int STOBJFLT(const StoreEntry *); +typedef struct { + StoreEntry *sentry; + int bucket; + STOBJFLT *filter; +} StatObjectsState; + /* LOCALS */ static const char *describeStatuses(const StoreEntry *); static const char *describeFlags(const StoreEntry *); @@ -130,6 +137,7 @@ static OBJH stat_vmobjects_get; #if DEBUG_OPENFD static OBJH statOpenfdObj; #endif +static EVH statObjects; static OBJH info_get; static OBJH statFiledescriptors; static OBJH statCountersDump; @@ -355,47 +363,78 @@ statStoreEntry(StoreEntry * s, StoreEntry * e) /* process objects list */ static void -statObjects(StoreEntry * sentry, int vm_or_not) +statObjects(void *data) { - StoreEntry *entry = NULL; - int N = 0; - hash_first(store_table); - while ((entry = (StoreEntry *) hash_next(store_table))) { - if (vm_or_not && entry->mem_obj == NULL) + StatObjectsState *state = data; + StoreEntry *e; + hash_link *link_ptr = NULL; + hash_link *link_next = NULL; + if (++state->bucket >= store_hash_buckets) { + storeComplete(state->sentry); + storeUnlockObject(state->sentry); + cbdataFree(state); + return; + } + storeBuffer(state->sentry); + debug(49, 3) ("statObjects: Bucket #%d\n", state->bucket); + link_next = hash_get_bucket(store_table, state->bucket); + while (NULL != (link_ptr = link_next)) { + link_next = link_ptr->next; + e = (StoreEntry *) link_ptr; + if (state->filter && 0 == state->filter(e)) continue; - if ((++N & 0xFF) == 0) { - debug(18, 3) ("statObjects: Processed %d objects...\n", N); - } - statStoreEntry(sentry, entry); + statStoreEntry(state->sentry, e); } + eventAdd("statObjects", statObjects, state, 0.0, 1); + storeBufferFlush(state->sentry); } static void -stat_objects_get(StoreEntry * e) +statObjectsStart(StoreEntry * sentry, STOBJFLT * filter) +{ + StatObjectsState *state = xcalloc(1, sizeof(*state)); + state->sentry = sentry; + state->filter = filter; + storeLockObject(sentry); + cbdataAdd(state, MEM_NONE); + eventAdd("statObjects", statObjects, state, 0.0, 1); +} + +static void +stat_objects_get(StoreEntry * sentry) +{ + statObjectsStart(sentry, NULL); +} + +static int +statObjectsVmFilter(const StoreEntry * e) { - statObjects(e, 0); + return e->mem_obj ? 1 : 0; } static void -stat_vmobjects_get(StoreEntry * e) +stat_vmobjects_get(StoreEntry * sentry) { - statObjects(e, 1); + statObjectsStart(sentry, statObjectsVmFilter); } #if DEBUG_OPENFD +static int +statObjectsOpenfdFilter(const StoreEntry * e) +{ + if (e->mem_obj == NULL) + return 0; + if (e->mem_obj->swapout.fd < 0) + return 0;; + return 1; +} + static void statOpenfdObj(StoreEntry * sentry) { - StoreEntry *entry = NULL; - hash_first(store_table); - while ((entry = (StoreEntry *) hash_next(store_table))) { - if (entry->mem_obj == NULL) - continue; - if (entry->mem_obj->swapout.fd < 0) - continue; - statStoreEntry(sentry, entry); - } + statObjectsStart(sentry, statObjectsOpenfdFilter); } + #endif #ifdef XMALLOC_STATISTICS @@ -775,50 +814,50 @@ statInit(void) eventAdd("statAvgTick", statAvgTick, NULL, (double) COUNT_INTERVAL, 1); cachemgrRegister("info", "General Runtime Information", - info_get, 0); + info_get, 0, 1); cachemgrRegister("filedescriptors", "Process Filedescriptor Allocation", - statFiledescriptors, 0); + statFiledescriptors, 0, 1); cachemgrRegister("objects", "All Cache Objects", - stat_objects_get, 0); + stat_objects_get, 0, 0); cachemgrRegister("vm_objects", "In-Memory and In-Transit Objects", - stat_vmobjects_get, 0); + stat_vmobjects_get, 0, 0); #if DEBUG_OPENFD cachemgrRegister("openfd_objects", "Objects with Swapout files open", - statOpenfdObj, 0); + statOpenfdObj, 0, 0); #endif cachemgrRegister("io", "Server-side network read() size histograms", - stat_io_get, 0); + stat_io_get, 0, 1); cachemgrRegister("counters", "Traffic and Resource Counters", - statCountersDump, 0); + statCountersDump, 0, 1); cachemgrRegister("peer_select", "Peer Selection Algorithms", - statPeerSelect, 0); + statPeerSelect, 0, 1); cachemgrRegister("digest_stats", "Cache Digest and ICP blob", - statDigestBlob, 0); + statDigestBlob, 0, 1); cachemgrRegister("5min", "5 Minute Average of Counters", - statAvg5min, 0); + statAvg5min, 0, 1); cachemgrRegister("60min", "60 Minute Average of Counters", - statAvg60min, 0); + statAvg60min, 0, 1); cachemgrRegister("utilization", "Cache Utilization", - statUtilization, 0); + statUtilization, 0, 1); #if STAT_GRAPHS cachemgrRegister("graph_variables", "Display cache metrics graphically", - statGraphDump, 0); + statGraphDump, 0, 1); #endif cachemgrRegister("histograms", "Full Histogram Counts", - statCountersHistograms, 0); + statCountersHistograms, 0, 1); } static void diff --git a/src/store.cc b/src/store.cc index fbcfb2be8e..9f49c4fb08 100644 --- a/src/store.cc +++ b/src/store.cc @@ -1,6 +1,6 @@ /* - * $Id: store.cc,v 1.428 1998/07/20 17:20:13 wessels Exp $ + * $Id: store.cc,v 1.429 1998/07/20 20:21:11 wessels Exp $ * * DEBUG: section 20 Storage Manager * AUTHOR: Harvest Derived @@ -855,7 +855,7 @@ storeInit(void) storeRebuildStart(); cachemgrRegister("storedir", "Store Directory Stats", - storeDirStats, 0); + storeDirStats, 0, 1); } void diff --git a/src/store_digest.cc b/src/store_digest.cc index bc5a49407a..64c38b142c 100644 --- a/src/store_digest.cc +++ b/src/store_digest.cc @@ -1,5 +1,5 @@ /* - * $Id: store_digest.cc,v 1.23 1998/07/20 17:20:15 wessels Exp $ + * $Id: store_digest.cc,v 1.24 1998/07/20 20:21:13 wessels Exp $ * * DEBUG: section 71 Store Digest Manager * AUTHOR: Alex Rousskov @@ -111,7 +111,7 @@ storeDigestInit(void) StoreDigestRebuildPeriod, StoreDigestRewritePeriod); memset(&sd_state, 0, sizeof(sd_state)); cachemgrRegister("store_digest", "Store Digest", - storeDigestReport, 0); + storeDigestReport, 0, 1); #else store_digest = NULL; debug(71, 3) ("Local cache digest is 'off'\n");