strncpy(n->network, inet_ntoa(networkFromInaddr(addr)), 15);
n->key = n->network;
hash_join(addr_table, (hash_link *) n);
- meta_data.netdb++;
+ meta_data.netdb_addrs++;
}
static void
return;
}
hash_remove_link(addr_table, hptr);
- meta_data.netdb--;
+ meta_data.netdb_addrs--;
}
static void
n->hosts = x;
hash_insert(host_table, x->name, n);
n->link_count++;
+ meta_data.netdb_hosts++;
}
static void
n = (netdbEntry *) hptr->item;
n->link_count--;
hash_delete_link(host_table, hptr);
+ meta_data.netdb_hosts--;
}
static netdbEntry *
int k = 0;
int list_count = 0;
int removed = 0;
- list = xcalloc(meta_data.netdb, sizeof(netdbEntry *));
+ list = xcalloc(meta_data.netdb_addrs, sizeof(netdbEntry *));
for (n = netdbGetFirst(addr_table); n; n = netdbGetNext(addr_table)) {
*(list + list_count) = n;
list_count++;
- if (list_count > meta_data.netdb)
+ if (list_count > meta_data.netdb_addrs)
fatal_dump("netdbPurgeLRU: list_count overflow");
}
qsort((char *) list,
sizeof(netdbEntry *),
(QS) netdbLRU);
for (k = 0; k < list_count; k++) {
- if (meta_data.netdb < NETDB_LOW_MARK)
+ if (meta_data.netdb_addrs < NETDB_LOW_MARK)
break;
netdbRelease(*(list + k));
removed++;
netdbAdd(struct in_addr addr, char *hostname)
{
netdbEntry *n;
- if (meta_data.netdb > NETDB_HIGH_MARK)
+ if (meta_data.netdb_addrs > NETDB_HIGH_MARK)
netdbPurgeLRU();
if ((n = netdbLookupAddr(addr)) == NULL) {
n = xcalloc(1, sizeof(netdbEntry));
"RTT",
"Hops",
"Hostnames");
- list = xcalloc(meta_data.netdb, sizeof(netdbEntry *));
+ list = xcalloc(meta_data.netdb_addrs, sizeof(netdbEntry *));
i = 0;
for (n = netdbGetFirst(addr_table); n; n = netdbGetNext(addr_table))
*(list + i++) = n;
netdbFreeMemory(void)
{
netdbEntry *e;
- netdbEntry **list;
+ netdbEntry **L1;
+ hash_link *h;
+ hash_link **L2;
+ struct _net_db_name *x;
int i = 0;
int j;
- list = xcalloc(meta_data.netdb, sizeof(netdbEntry));
+
+ L1 = xcalloc(meta_data.netdb_addrs, sizeof(netdbEntry));
e = (netdbEntry *) hash_first(addr_table);
- while (e && i < meta_data.netdb) {
- *(list + i) = e;
+ while (e && i < meta_data.netdb_addrs) {
+ *(L1 + i) = e;
i++;
e = (netdbEntry *) hash_next(addr_table);
}
for (j = 0; j < i; j++)
- xfree(*(list + j));
- xfree(list);
+ xfree(*(L1 + j));
+ xfree(L1);
+
+ i = 0;
+ L2 = xcalloc(meta_data.netdb_hosts, sizeof(netdbEntry));
+ h = hash_first(host_table);
+ while (h && i < meta_data.netdb_hosts) {
+ *(L2 + i) = h;
+ i++;
+ h = hash_next(host_table);
+ }
+ for (j = 0; j < i; j++) {
+ h = *(L2 + j);
+ x = (struct _net_db_name *) h->item;
+ xfree(x->name);
+ xfree(x);
+ xfree(h);
+ }
+ xfree(L2);
+
hashFreeMemory(addr_table);
hashFreeMemory(host_table);
}
/*
- * $Id: stat.cc,v 1.80 1996/10/09 22:49:43 wessels Exp $
+ * $Id: stat.cc,v 1.81 1996/10/10 16:38:50 wessels Exp $
*
* DEBUG: section 18 Cache Manager Statistics
* AUTHOR: Harvest Derived
mem_obj_pool.total_pages_allocated * mem_obj_pool.page_size +
meta_data.url_strings +
#if USE_ICMP
- meta_data.netdb * sizeof(netdbEntry) +
+ meta_data.netdb_addrs * sizeof(netdbEntry) +
+ meta_data.netdb_hosts * sizeof(struct _net_db_name) +
#endif
meta_data.misc;
}
#if USE_ICMP
storeAppendPrintf(sentry, "{\t%-25.25s %7d x %4d bytes = %6d KB}\n",
- "Network Data Entries",
- meta_data.netdb,
+ "NetDB Address Entries",
+ meta_data.netdb_addrs,
(int) sizeof(netdbEntry),
- (int) (meta_data.netdb * sizeof(netdbEntry) >> 10));
+ (int) (meta_data.netdb_addrs * sizeof(netdbEntry) >> 10));
+
+ storeAppendPrintf(sentry, "{\t%-25.25s %7d x %4d bytes = %6d KB}\n",
+ "NetDB Host Entries",
+ meta_data.netdb_hosts,
+ (int) sizeof(struct _net_db_name),
+ (int) (meta_data.netdb_hosts * sizeof(struct _net_db_name) >> 10));
#endif
storeAppendPrintf(sentry, "{\t%-25.25s = %6d KB}\n",