/*
- * $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
httpHdrCcInitModule();
/* register with cache manager */
cachemgrRegister("http_headers",
- "HTTP Header Statistics", httpHeaderStoreReport, 0);
+ "HTTP Header Statistics", httpHeaderStoreReport, 0, 1);
}
void
/*
- * $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
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
/*
- * $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
cachemgrRegister("config",
"Current Squid Configuration",
dump_config,
- 1);
+ 1, 1);
return 0;
}
/*
- * $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
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;
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;
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);
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)
/* 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 */
httpReplySwapOut(rep, entry);
}
a->handler(entry);
- storeBufferFlush(entry);
- storeComplete(entry);
+ if (a->flags.atomic) {
+ storeBufferFlush(entry);
+ storeComplete(entry);
+ }
cachemgrStateFree(mgr);
}
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)
{
cachemgrRegister("menu",
"This Cachemanager Menu",
- cachemgrMenu, 0);
+ cachemgrMenu, 0, 1);
cachemgrRegister("shutdown",
"Shut Down the Squid Process",
- cachemgrShutdown, 1);
+ cachemgrShutdown, 1, 1);
}
/*
- * $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
htable = hash_create(cbdata_cmp, 1 << 8, cbdata_hash);
cachemgrRegister("cbdata",
"Callback Data Registry Contents",
- cbdataDump, 0);
+ cbdataDump, 0, 1);
}
void
/*
- * $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
cachemgrRegister("client_list",
"Cache Client List",
clientdbDump,
- 0);
+ 0, 1);
}
void
/*
- * $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
invert32[i] = (int) (32.0 / (double) i + 0.5);
cachemgrRegister("comm_incoming",
"comm_incoming() stats",
- commIncomingStats, 0);
+ commIncomingStats, 0, 1);
}
/*
- * $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
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);
}
/*
- * $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
{
cachemgrRegister("events",
"Event Queue",
- eventDump, 0);
+ eventDump, 0, 1);
}
static void
/*
- * $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
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 */
/*
- * $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
ip_table = hash_create(urlcmp, n, hash4);
cachemgrRegister("ipcache",
"IP Cache Stats and Contents",
- stat_ipcache_get, 0);
+ stat_ipcache_get, 0, 1);
}
int
/*
- * $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
}
cachemgrRegister("mem",
"Memory Utilization",
- memStats, 0);
+ memStats, 0, 1);
}
void
/*
- * $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
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
/*
- * $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
netdbReloadState();
cachemgrRegister("netdb",
"Network Measurement Database",
- netdbDump, 0);
+ netdbDump, 0, 1);
#endif
}
/*
- * $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
}
cachemgrRegister("pconn",
"Persistent Connection Utilization Histograms",
- pconnHistDump, 0);
+ pconnHistDump, 0, 1);
debug(48, 3) ("persistent connection module initialized\n");
}
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);
/*
- * $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
memset(&RedirectStats, '\0', sizeof(RedirectStats));
cachemgrRegister("redirector",
"URL Redirector Stats",
- redirectStats, 0);
+ redirectStats, 0, 1);
}
safe_free(short_prg);
safe_free(short_prg2);
/*
- * $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
#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 *);
#if DEBUG_OPENFD
static OBJH statOpenfdObj;
#endif
+static EVH statObjects;
static OBJH info_get;
static OBJH statFiledescriptors;
static OBJH statCountersDump;
/* 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
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
/*
- * $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
storeRebuildStart();
cachemgrRegister("storedir",
"Store Directory Stats",
- storeDirStats, 0);
+ storeDirStats, 0, 1);
}
void
/*
- * $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
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");