/*
- * $Id: access_log.cc,v 1.28 1998/04/09 21:32:08 wessels Exp $
+ * $Id: access_log.cc,v 1.29 1998/05/24 03:41:06 wessels Exp $
*
* DEBUG: section 46 Access Log
* AUTHOR: Duane Wessels
fvdb_entry *fv;
if (hash == NULL)
return;
- for (h = hash_first(hash); h != NULL; h = hash_next(hash)) {
+ hash_first(hash);
+ while (h = hash_next(hash)) {
fv = (fvdb_entry *) h;
storeAppendPrintf(e, "%9d %s\n", fv->n, fv->key);
}
/*
- * $Id: cache_diff.cc,v 1.7 1998/03/31 05:37:35 wessels Exp $
+ * $Id: cache_diff.cc,v 1.8 1998/05/24 03:41:06 wessels Exp $
*
* AUTHOR: Alex Rousskov
*
hash_link *hashr = NULL;
if (idx) {
/* destroy hash list contents */
- for (hashr = hash_first(idx->hash); hashr; hashr = hash_next(idx->hash)) {
+ hash_first(idx->hash);
+ while (hashr = hash_next(idx->hash)) {
hash_remove_link(idx->hash, hashr);
cacheEntryDestroy((CacheEntry *) hashr);
}
large_idx = idx1;
}
/* find shared_count */
- for (hashr = hash_first(small_idx->hash); hashr; hashr = hash_next(small_idx->hash)) {
+ hash_first(small_idx->hash);
+ for (hashr = hash_next(small_idx->hash)) {
hashed_count++;
if (hash_lookup(large_idx->hash, hashr->key))
shared_count++;
/*
- * $Id: cbdata.cc,v 1.20 1998/05/12 20:16:32 wessels Exp $
+ * $Id: cbdata.cc,v 1.21 1998/05/24 03:41:07 wessels Exp $
*
* DEBUG: section 45 Callback Data Registry
* AUTHOR: Duane Wessels
hash_link *hptr;
cbdata *c;
storeAppendPrintf(sentry, "%d cbdata entries\n", cbdataCount);
- for (hptr = hash_first(htable); hptr; hptr = hash_next(htable)) {
+ hash_first(htable);
+ while ((hptr = hash_next(htable))) {
c = (cbdata *) hptr;
#if CBDATA_DEBUG
storeAppendPrintf(sentry, "%20p %10s %d locks %s:%d\n",
/*
- * $Id: client_db.cc,v 1.31 1998/04/24 05:44:08 wessels Exp $
+ * $Id: client_db.cc,v 1.32 1998/05/24 03:41:08 wessels Exp $
*
* DEBUG: section 0 Client Database
* AUTHOR: Duane Wessels
int http_total = 0;
int http_hits = 0;
storeAppendPrintf(sentry, "Cache Clients:\n");
- c = (ClientInfo *) hash_first(client_table);
- while (c) {
+ hash_first(client_table);
+ while ((c = (ClientInfo *) hash_next(client_table))) {
storeAppendPrintf(sentry, "Address: %s\n", c->key);
storeAppendPrintf(sentry, "Name: %s\n", fqdnFromAddr(c->addr));
storeAppendPrintf(sentry, " ICP Requests %d\n",
percent(c->Http.result_hist[l], c->Http.n_requests));
}
storeAppendPrintf(sentry, "\n");
- c = (ClientInfo *) hash_next(client_table);
}
storeAppendPrintf(sentry, "TOTALS\n");
storeAppendPrintf(sentry, "ICP : %d Queries, %d Hits (%3d%%)\n",
ClientInfo *c = NULL;
static char key[15];
- if (!Oid[0] && !Oid[1] && !Oid[2] && !Oid[3])
- c = (ClientInfo *) hash_first(client_table);
- else {
+ if (!Oid[0] && !Oid[1] && !Oid[2] && !Oid[3]) {
+ hash_first(client_table);
+ c = (ClientInfo *) hash_next(client_table);
+ } else {
snprintf(key, 15, "%d.%d.%d.%d", Oid[0], Oid[1], Oid[2], Oid[3]);
c = (ClientInfo *) hash_lookup(client_table, key);
if (NULL != c)
ClientInfo *c = NULL;
int aggr = 0;
log_type l;
-#if 0
- int cnt;
-#endif
Answer = snmp_var_new(Var->name, Var->name_length);
*ErrP = SNMP_ERR_NOERROR;
Var->name[13], Var->name[14]);
debug(49, 5) ("snmp_meshCtblFn: [%s] requested!\n", key);
c = (ClientInfo *) hash_lookup(client_table, key);
-#if 0
- c = (ClientInfo *) hash_first(client_table);
- cnt = Var->name[11];
- debug(49, 5) ("snmp_meshCtblFn: we want .x.%d\n", Var->name[10]);
- while (--cnt)
- if (!(c = (ClientInfo *) hash_next(client_table)));
-#endif
if (c == NULL) {
debug(49, 5) ("snmp_meshCtblFn: not found.\n");
*ErrP = SNMP_ERR_NOSUCHNAME;
/*
- * $Id: fqdncache.cc,v 1.103 1998/05/22 23:44:05 wessels Exp $
+ * $Id: fqdncache.cc,v 1.104 1998/05/24 03:41:08 wessels Exp $
*
* DEBUG: section 35 FQDN Cache
* AUTHOR: Harvest Derived
fqdnStats(StoreEntry * sentry)
{
fqdncache_entry *f = NULL;
- fqdncache_entry *next = NULL;
int k;
int ttl;
if (fqdn_table == NULL)
FqdncacheStats.ghba_calls);
storeAppendPrintf(sentry, "FQDN Cache Contents:\n\n");
- next = (fqdncache_entry *) hash_first(fqdn_table);
- while ((f = next) != NULL) {
- next = (fqdncache_entry *) hash_next(fqdn_table);
+ hash_first(fqdn_table);
+ while ((f = (fqdncache_entry *) hash_next(fqdn_table))) {
if (f->status == FQDN_PENDING || f->status == FQDN_DISPATCHED)
ttl = 0;
else
fqdncache_restart(void)
{
fqdncache_entry *this;
- fqdncache_entry *next;
if (fqdn_table == 0)
fatal_dump("fqdncache_restart: fqdn_table == 0\n");
while (fqdncacheDequeue());
- next = (fqdncache_entry *) hash_first(fqdn_table);
- while ((this = next) != NULL) {
- next = (fqdncache_entry *) hash_next(fqdn_table);
+ hash_first(fqdn_table);
+ while ((this = (fqdncache_entry *) hash_next(fqdn_table))) {
if (this->status == FQDN_CACHED)
continue;
if (this->status == FQDN_NEGATIVE_CACHED)
int i = 0;
fqdncache_entry *fq = NULL;
- fq = (fqdncache_entry *) hash_first(fqdn_table);
- if (fq != NULL) {
- i = 1;
- while ((fq = (fqdncache_entry *) hash_next(fqdn_table)))
- i++;
- }
+ hash_first(fqdn_table);
+ while ((fq = (fqdncache_entry *) hash_next(fqdn_table)))
+ i++;
return i;
}
cnt = Var->name[12];
- fq = (fqdncache_entry *) hash_first(fqdn_table);
- while (fq && --cnt)
+ hash_first(fqdn_table);
+ while (cnt--) {
fq = (fqdncache_entry *) hash_next(fqdn_table);
+ if (NULL == fq)
+ break;
+ }
if (fq == NULL || cnt != 0) {
*ErrP = SNMP_ERR_NOSUCHNAME;
return NULL;
/*
- * $Id: ipcache.cc,v 1.187 1998/05/15 15:16:23 wessels Exp $
+ * $Id: ipcache.cc,v 1.188 1998/05/24 03:41:10 wessels Exp $
*
* DEBUG: section 14 IP Cache
* AUTHOR: Harvest Derived
ipcache_restart(void)
{
ipcache_entry *this;
- ipcache_entry *next;
assert(ip_table != NULL);
while (ipcacheDequeue());
- next = (ipcache_entry *) hash_first(ip_table);
- while ((this = next) != NULL) {
- next = (ipcache_entry *) hash_next(ip_table);
+ hash_first(ip_table);
+ while ((this = (ipcache_entry *) hash_next(ip_table))) {
if (this->status == IP_CACHED)
continue;
if (this->status == IP_NEGATIVE_CACHED)
/*
- * $Id: net_db.cc,v 1.106 1998/05/22 23:44:19 wessels Exp $
+ * $Id: net_db.cc,v 1.107 1998/05/24 03:41:11 wessels Exp $
*
* DEBUG: section 37 Network Measurement Database
* AUTHOR: Duane Wessels
int list_count = 0;
int removed = 0;
list = xcalloc(memInUse(MEM_NETDBENTRY), sizeof(netdbEntry *));
- n = (netdbEntry *) hash_first(addr_table);
- while (n != NULL) {
+ hash_first(addr_table);
+ while ((n = (netdbEntry *) hash_next(addr_table))) {
assert(list_count < memInUse(MEM_NETDBENTRY));
*(list + list_count) = n;
list_count++;
- n = (netdbEntry *) hash_next(addr_table);
}
qsort((char *) list,
list_count,
LOCAL_ARRAY(char, path, SQUID_MAXPATHLEN);
FILE *fp;
netdbEntry *n;
- netdbEntry *next;
net_db_name *x;
struct timeval start = current_time;
int count = 0;
debug(50, 1) ("netdbSaveState: %s: %s\n", path, xstrerror());
return;
}
- next = (netdbEntry *) hash_first(addr_table);
- while ((n = next) != NULL) {
- next = (netdbEntry *) hash_next(addr_table);
+ hash_first(addr_table);
+ while ((n = (netdbEntry *) hash_next(addr_table))) {
if (n->pings_recv == 0)
continue;
fprintf(fp, "%s %d %d %10.5f %10.5f %d %d",
"Hostnames");
list = xcalloc(memInUse(MEM_NETDBENTRY), sizeof(netdbEntry *));
i = 0;
- n = (netdbEntry *) hash_first(addr_table);
- while (n != NULL) {
+ hash_first(addr_table);
+ while ((n = (netdbEntry *) hash_next(addr_table)))
*(list + i++) = n;
- n = (netdbEntry *) hash_next(addr_table);
- }
if (i != memInUse(MEM_NETDBENTRY))
debug(37, 0) ("WARNING: netdb_addrs count off, found %d, expected %d\n",
i, memInUse(MEM_NETDBENTRY));
http_reply *reply = s->mem_obj->reply;
#if USE_ICMP
netdbEntry *n;
- netdbEntry *next;
int i;
int j;
int rec_sz;
rec_sz += 1 + sizeof(int);
buf = memAllocate(MEM_4K_BUF);
i = 0;
- next = (netdbEntry *) hash_first(addr_table);
- while (next != NULL) {
- n = next;
- next = (netdbEntry *) hash_next(addr_table);
+ hash_first(addr_table);
+ while ((n = (netdbEntry *) hash_next(addr_table))) {
if (0.0 == n->rtt)
continue;
if (n->rtt > 60000) /* RTT > 1 MIN probably bogus */
extern void hash_remove_link(hash_table *, hash_link *);
extern int hashPrime(int n);
extern void *hash_lookup(hash_table *, const void *);
-extern void *hash_first(hash_table *);
+extern void hash_first(hash_table *);
extern void *hash_next(hash_table *);
extern hash_link *hash_get_bucket(hash_table *, unsigned int);
extern void hashFreeMemory(hash_table *);
/*
- * $Id: stat.cc,v 1.253 1998/05/22 23:44:26 wessels Exp $
+ * $Id: stat.cc,v 1.254 1998/05/24 03:41:13 wessels Exp $
*
* DEBUG: section 18 Cache Manager Statistics
* AUTHOR: Harvest Derived
statObjects(StoreEntry * sentry, int vm_or_not)
{
StoreEntry *entry = NULL;
- StoreEntry *next = NULL;
int N = 0;
- next = (StoreEntry *) hash_first(store_table);
- while ((entry = next) != NULL) {
- next = (StoreEntry *) hash_next(store_table);
+ hash_first(store_table);
+ while ((entry = (StoreEntry *) hash_next(store_table))) {
if (vm_or_not && entry->mem_obj == NULL)
continue;
if ((++N & 0xFF) == 0) {
statOpenfdObj(StoreEntry * sentry)
{
StoreEntry *entry = NULL;
- StoreEntry *next = NULL;
- next = (StoreEntry *) hash_first(store_table);
- while ((entry = next) != NULL) {
- next = (StoreEntry *) hash_next(store_table);
+ hash_first(store_table);
+ while ((entry = (StoreEntry *) hash_next(store_table))) {
if (entry->mem_obj == NULL)
continue;
if (entry->mem_obj->swapout.fd < 0)
HASHHASH *hash;
unsigned int size;
unsigned int current_slot;
- hash_link **Current;
+ hash_link *next;
int count;
};
/*
- * $Id: test_cache_digest.cc,v 1.19 1998/04/24 07:09:49 wessels Exp $
+ * $Id: test_cache_digest.cc,v 1.20 1998/05/24 03:41:15 wessels Exp $
*
* AUTHOR: Alex Rousskov
*
assert(cache);
hash = cache->hash;
/* destroy hash table contents */
- for (e = hash_first(hash); e; e = hash_next(hash)) {
+ hash_first(hash);
+ while (e = hash_next(hash)) {
hash_remove_link(hash, (hash_link *) e);
cacheEntryDestroy(e);
}
if (!cache->count)
return;
gettimeofday(&t_start, NULL);
- for (e = hash_first(hash); e; e = hash_next(hash)) {
+ hash_first(hash);
+ while (e = hash_next(hash)) {
cacheDigestAdd(cache->digest, e->key);
}
gettimeofday(&t_end, NULL);