/*
- * $Id: client_db.cc,v 1.24 1998/03/13 05:38:13 wessels Exp $
+ * $Id: client_db.cc,v 1.25 1998/03/24 17:29:43 wessels Exp $
*
* DEBUG: section 0 Client Database
* AUTHOR: Duane Wessels
{
if (client_table)
return;
- client_table = hash_create((HASHCMP *) strcmp, 229, hash_string);
+ client_table = hash_create((HASHCMP *) strcmp, 467, hash_string);
cachemgrRegister("client_list",
"Cache Client List",
clientdbDump,
/*
- * $Id: comm.cc,v 1.234 1998/03/20 06:51:44 wessels Exp $
+ * $Id: comm.cc,v 1.235 1998/03/24 17:29:44 wessels Exp $
*
* DEBUG: section 5 Socket Functions
* AUTHOR: Harvest Derived
void
comm_write(int fd, char *buf, int size, CWCB * handler, void *handler_data, FREE * free_func)
{
- CommWriteStateData *state = NULL;
+ CommWriteStateData *state = fd_table[fd].rwstate;
debug(5, 5) ("comm_write: FD %d: sz %d: hndl %p: data %p.\n",
fd, size, handler, handler_data);
- if (fd_table[fd].rwstate) {
+ if (NULL != state) {
debug(5, 1) ("comm_write: fd_table[%d].rwstate != NULL", fd);
- state = fd_table[fd].rwstate;
- debug(5, 1) ("comm_write: %d'%s',(%d,%d)'%s'\n", size, buf, state->size,
- state->offset, state->buf);
- safe_free(fd_table[fd].rwstate);
+ safe_free(state);
fd_table[fd].rwstate = NULL;
}
- assert(fd_table[fd].rwstate == NULL);
- state = xcalloc(1, sizeof(CommWriteStateData));
+ assert(state == NULL);
+ fd_table[fd].rwstate = state = xcalloc(1, sizeof(CommWriteStateData));
state->buf = buf;
state->size = size;
state->offset = 0;
state->handler = handler;
state->handler_data = handler_data;
state->free_func = free_func;
- fd_table[fd].rwstate = state;
cbdataLock(handler_data);
- commSetSelect(fd,
- COMM_SELECT_WRITE,
- commHandleWrite,
- fd_table[fd].rwstate,
- 0);
+ commSetSelect(fd, COMM_SELECT_WRITE, commHandleWrite, state, 0);
}
/* a wrapper around comm_write to allow for MemBuf to comm_written in a snap */
/*
- * $Id: fqdncache.cc,v 1.92 1998/03/21 22:06:00 kostas Exp $
+ * $Id: fqdncache.cc,v 1.93 1998/03/24 17:29:45 wessels Exp $
*
* DEBUG: section 35 FQDN Cache
* AUTHOR: Harvest Derived
void
fqdncache_init(void)
{
+ int n;
if (fqdn_table)
return;
debug(35, 3) ("Initializing FQDN Cache...\n");
memset(&FqdncacheStats, '\0', sizeof(FqdncacheStats));
- /* small hash table */
- fqdn_table = hash_create(urlcmp, 229, hash4);
fqdncache_high = (long) (((float) MAX_FQDN *
(float) FQDN_HIGH_WATER) / (float) 100);
fqdncache_low = (long) (((float) MAX_FQDN *
(float) FQDN_LOW_WATER) / (float) 100);
+ n = hashPrime(fqdncache_high / 4);
+ fqdn_table = hash_create(urlcmp, n, hash4);
cachemgrRegister("fqdncache",
"FQDN Cache Stats and Contents",
fqdnStats, 0);
/*
- * $Id: ipcache.cc,v 1.170 1998/03/21 22:06:01 kostas Exp $
+ * $Id: ipcache.cc,v 1.171 1998/03/24 17:29:46 wessels Exp $
*
* DEBUG: section 14 IP Cache
* AUTHOR: Harvest Derived
void
ipcache_init(void)
{
+ int n;
debug(14, 3) ("Initializing IP Cache...\n");
memset(&IpcacheStats, '\0', sizeof(IpcacheStats));
debug(14, 1) ("Successful DNS name lookup tests...\n");
}
- ip_table = hash_create(urlcmp, 229, hash4); /* small hash table */
memset(&static_addrs, '\0', sizeof(ipcache_addrs));
static_addrs.in_addrs = xcalloc(1, sizeof(struct in_addr));
static_addrs.bad_mask = xcalloc(1, sizeof(unsigned char));
(float) Config.ipcache.high) / (float) 100);
ipcache_low = (long) (((float) Config.ipcache.size *
(float) Config.ipcache.low) / (float) 100);
+ n = hashPrime(ipcache_high / 4);
+ ip_table = hash_create(urlcmp, n, hash4);
cachemgrRegister("ipcache",
"IP Cache Stats and Contents",
stat_ipcache_get, 0);
/*
- * $Id: net_db.cc,v 1.75 1998/03/21 22:06:02 kostas Exp $
+ * $Id: net_db.cc,v 1.76 1998/03/24 17:29:47 wessels Exp $
*
* DEBUG: section 37 Network Measurement Database
* AUTHOR: Duane Wessels
netdbInit(void)
{
#if USE_ICMP
+ int n;
if (addr_table)
return;
- addr_table = hash_create((HASHCMP *) strcmp, 229, hash_string);
- host_table = hash_create((HASHCMP *) strcmp, 467, hash_string);
+ n = hashPrime(Config.Netdb.high / 4);
+ addr_table = hash_create((HASHCMP *) strcmp, n, hash_string);
+ n = hashPrime(3 * Config.Netdb.high / 4);
+ host_table = hash_create((HASHCMP *) strcmp, n, hash_string);
eventAdd("netdbSaveState", netdbSaveState, NULL, 3617);
netdbReloadState();
cachemgrRegister("netdb",
extern int hash_delete_link(hash_table *, hash_link *);
extern void hash_join(hash_table *, hash_link *);
extern int hash_remove_link(hash_table *, hash_link *);
+extern int hashPrime(int n);
/* searching, accessing */
extern hash_link *hash_lookup(hash_table *, const void *);