/* * mon_stop - stop the monitoring software */ void mon_stop( int mode ) { mon_entry *mon; if (MON_OFF == mon_enabled) return; if ((mon_enabled & mode) == 0 || mode == MON_OFF) return; mon_enabled &= ~mode; if (mon_enabled != MON_OFF) return; /* * Move everything on the MRU list to the free list quickly, * without bothering to remove each from either the MRU list or * the hash table. */ ITER_DLIST_BEGIN(mon_mru_list, mon, mru, mon_entry) mon_free_entry(mon); ITER_DLIST_END() /* empty the MRU list and hash table. */ mru_entries = 0; INIT_DLIST(mon_mru_list, mru); zero_mem(mon_hash, sizeof(*mon_hash) * MON_HASH_SIZE); }
/* * auth_resize_hashtable * * Size hash table to average 4 or fewer entries per bucket initially, * within the bounds of at least 4 and no more than 15 bits for the hash * table index. Populate the hash table. */ static void auth_resize_hashtable(void) { u_long totalkeys; u_short hashbits; u_short hash; size_t newalloc; symkey * sk; totalkeys = authnumkeys + authnumfreekeys; hashbits = auth_log2(totalkeys / 4.0) + 1; hashbits = max(4, hashbits); hashbits = min(15, hashbits); authhashbuckets = 1 << hashbits; authhashmask = authhashbuckets - 1; newalloc = authhashbuckets * sizeof(key_hash[0]); key_hash = erealloc(key_hash, newalloc); memset(key_hash, '\0', newalloc); ITER_DLIST_BEGIN(key_listhead, sk, llink, symkey) hash = KEYHASH(sk->keyid); LINK_SLIST(key_hash[hash], sk, hlink); ITER_DLIST_END() }