Lines Matching refs:nscdb
447 hash_find(nsc_db_t *nscdb, nsc_entry_t *entry, uint_t *hash, in hash_find() argument
453 if (nscdb->gethash) in hash_find()
454 *hash = nscdb->gethash(&entry->key, nscdb->htsize); in hash_find()
458 hashentry = nscdb->htable[*hash]; in hash_find()
461 if (nscdb->compar) { in hash_find()
462 if (nscdb->compar(entry, hashentry) == 0) in hash_find()
469 #define HASH_REMOVE(nscdb, entry, hash, cmp) \ argument
470 if (nscdb->htable) { \
471 if (entry == hash_find(nscdb, entry, &hash, cmp)) \
472 nscdb->htable[hash] = NULL; \
476 #define HASH_INSERT(nscdb, entry, hash, cmp) \ argument
477 if (nscdb->htable) { \
478 (void) hash_find(nscdb, entry, &hash, cmp); \
479 nscdb->htable[hash] = entry; \
485 print_entry(nsc_db_t *nscdb, time_t now, nsc_entry_t *entry) in print_entry() argument
516 (void) nscdb->getlogstr(nscdb->name, whoami, sizeof (whoami), &args); in print_entry()
578 hash_dump(nsc_db_t *nscdb, time_t now) in hash_dump() argument
584 for (i = 0; i < nscdb->htsize; i++) { in hash_dump()
585 if ((entry = nscdb->htable[i]) != NULL) { in hash_dump()
587 print_entry(nscdb, now, entry); in hash_dump()
596 avl_dump(nsc_db_t *nscdb, time_t now) in avl_dump() argument
602 for (entry = avl_first(&nscdb->tree), i = 0; entry != NULL; in avl_dump()
603 entry = avl_walk(&nscdb->tree, entry, AVL_AFTER)) { in avl_dump()
605 print_entry(nscdb, now, entry); in avl_dump()
613 queue_dump(nsc_db_t *nscdb, time_t now) in queue_dump() argument
620 nscdb->name, avl_numnodes(&nscdb->tree)); in queue_dump()
625 for (entry = nscdb->qtail, i = 0; entry; entry = entry->qnext) { in queue_dump()
627 print_entry(nscdb, now, entry); in queue_dump()
633 queue_remove(nsc_db_t *nscdb, nsc_entry_t *entry) in queue_remove() argument
636 if (nscdb->qtail == entry) in queue_remove()
637 nscdb->qtail = entry->qnext; in queue_remove()
641 if (nscdb->qhead == entry) in queue_remove()
642 nscdb->qhead = entry->qprev; in queue_remove()
646 if (nscdb->reap_node == entry) in queue_remove()
647 nscdb->reap_node = entry->qnext; in queue_remove()
653 queue_adjust(nsc_db_t *nscdb, nsc_entry_t *entry) in queue_adjust() argument
657 assert(nscdb->qtail || entry->qnext == NULL && in queue_adjust()
660 assert(nscdb->qtail && nscdb->qhead || in queue_adjust()
661 nscdb->qtail == NULL && nscdb->qhead == NULL); in queue_adjust()
664 nscdb->qtail == entry); in queue_adjust()
668 if (nscdb->qtail == entry) in queue_adjust()
672 if (nscdb->qtail == NULL) { in queue_adjust()
673 nscdb->qhead = nscdb->qtail = entry; in queue_adjust()
679 nscdb->qtail->qprev = entry; in queue_adjust()
680 entry->qnext = nscdb->qtail; in queue_adjust()
681 nscdb->qtail = entry; in queue_adjust()
686 if (nscdb->reap_node == entry) in queue_adjust()
687 nscdb->reap_node = entry->qnext; in queue_adjust()
688 if (nscdb->qhead == entry) in queue_adjust()
689 nscdb->qhead = entry->qprev; in queue_adjust()
694 entry->qnext = nscdb->qtail; in queue_adjust()
695 nscdb->qtail->qprev = entry; in queue_adjust()
696 nscdb->qtail = entry; in queue_adjust()
727 nsc_db_t *nscdb; in make_cache() local
730 nscdb = (nsc_db_t *)malloc(sizeof (*nscdb)); in make_cache()
731 if (nscdb == NULL) { in make_cache()
736 (void) memset(nscdb, 0, sizeof (*nscdb)); in make_cache()
738 nscdb->dbop = dbop; in make_cache()
739 nscdb->name = name; in make_cache()
740 nscdb->db_type = dbtype; in make_cache()
744 if (_NSC_DB_CES_KEY(nscdb)) in make_cache()
745 nscdb->compar = nsc_db_ces_key_compar; in make_cache()
746 else if (_NSC_DB_CIS_KEY(nscdb)) in make_cache()
747 nscdb->compar = nsc_db_cis_key_compar; in make_cache()
748 else if (_NSC_DB_INT_KEY(nscdb)) in make_cache()
749 nscdb->compar = nsc_db_int_key_compar; in make_cache()
753 nscdb->compar = compar; in make_cache()
757 avl_create(&nscdb->tree, nscdb->compar, sizeof (nsc_entry_t), in make_cache()
762 if (_NSC_DB_STR_KEY(nscdb)) in make_cache()
763 nscdb->getlogstr = nsc_db_str_key_getlogstr; in make_cache()
764 else if (_NSC_DB_INT_KEY(nscdb)) in make_cache()
765 nscdb->getlogstr = nsc_db_int_key_getlogstr; in make_cache()
767 nscdb->getlogstr = nsc_db_any_key_getlogstr; in make_cache()
769 nscdb->getlogstr = getlogstr; in make_cache()
775 nscdb->hash_type = httype; in make_cache()
787 nscdb->htsize = htsize; in make_cache()
790 nscdb->htable = calloc(htsize, sizeof (*(nscdb->htable))); in make_cache()
791 if (nscdb->htable == NULL) { in make_cache()
799 if (_NSC_DB_CES_KEY(nscdb)) in make_cache()
800 nscdb->gethash = nsc_db_ces_key_gethash; in make_cache()
801 else if (_NSC_DB_CIS_KEY(nscdb)) in make_cache()
802 nscdb->gethash = nsc_db_cis_key_gethash; in make_cache()
803 else if (_NSC_DB_INT_KEY(nscdb)) in make_cache()
804 nscdb->gethash = nsc_db_int_key_gethash; in make_cache()
808 nscdb->gethash = gethash; in make_cache()
812 (void) mutex_init(&nscdb->db_mutex, USYNC_THREAD, NULL); in make_cache()
813 return (nscdb); in make_cache()
816 if (nscdb->htable) in make_cache()
817 free(nscdb->htable); in make_cache()
818 if (nscdb) in make_cache()
819 free(nscdb); in make_cache()
1075 nsc_db_t *nscdb; in nsc_dump() local
1105 nscdb = nsc_get_db(ctx, dbop); in nsc_dump()
1106 if (nscdb == NULL) { in nsc_dump()
1112 (void) mutex_lock(&nscdb->db_mutex); in nsc_dump()
1113 (void) queue_dump(nscdb, now); in nsc_dump()
1114 (void) hash_dump(nscdb, now); in nsc_dump()
1115 (void) avl_dump(nscdb, now); in nsc_dump()
1116 (void) mutex_unlock(&nscdb->db_mutex); in nsc_dump()
1275 nsc_db_t *nscdb; in check_config() local
1280 nscdb = largs->nscdb; in check_config()
1283 if (nscdb->cfg_mtime != ctx->cfg_mtime) { in check_config()
1285 nscdb->cfg = ctx->cfg; in check_config()
1286 nscdb->cfg_mtime = ctx->cfg_mtime; in check_config()
1290 ctx->dbname, nscdb->name); in check_config()
1292 *cfgp = nscdb->cfg; in check_config()
1377 nsc_db_t *nscdb; in lookup_int() local
1416 if (largs->nscdb == NULL) { in lookup_int()
1417 if ((largs->nscdb = nsc_get_db(ctx, dbop)) == NULL) { in lookup_int()
1429 nscdb = largs->nscdb; in lookup_int()
1432 (void) nscdb->getlogstr(nscdb->name, whoami, in lookup_int()
1454 (void) mutex_lock(&nscdb->db_mutex); in lookup_int()
1461 (void) mutex_unlock(&nscdb->db_mutex); in lookup_int()
1485 (void) mutex_unlock(&nscdb->db_mutex); in lookup_int()
1494 (void) mutex_unlock(&nscdb->db_mutex); in lookup_int()
1501 (void) mutex_unlock(&nscdb->db_mutex); in lookup_int()
1535 (void) mutex_unlock(&nscdb->db_mutex); in lookup_int()
1541 (void) nscd_wait(ctx, nscdb, this_entry); in lookup_int()
1560 delete_entry(nscdb, ctx, this_entry); in lookup_int()
1566 (void) mutex_unlock(&nscdb->db_mutex); in lookup_int()
1577 (void) mutex_unlock(&nscdb->db_mutex); in lookup_int()
1580 (void) mutex_lock(&nscdb->db_mutex); in lookup_int()
1585 (void) nscd_signal(ctx, nscdb, this_entry); in lookup_int()
1600 delete_entry(nscdb, ctx, this_entry); in lookup_int()
1601 (void) mutex_unlock(&nscdb->db_mutex); in lookup_int()
1614 delete_entry(nscdb, ctx, this_entry); in lookup_int()
1615 (void) mutex_unlock(&nscdb->db_mutex); in lookup_int()
1642 (void) mutex_unlock(&nscdb->db_mutex); in lookup_int()
1655 delete_entry(nscdb, ctx, this_entry); in lookup_int()
1656 (void) mutex_unlock(&nscdb->db_mutex); in lookup_int()
1665 delete_entry(nscdb, ctx, this_entry); in lookup_int()
1666 (void) mutex_unlock(&nscdb->db_mutex); in lookup_int()
1677 delete_entry(nscdb, ctx, this_entry); in lookup_int()
1678 (void) mutex_unlock(&nscdb->db_mutex); in lookup_int()
1701 (void) mutex_unlock(&nscdb->db_mutex); in lookup_int()
1714 delete_entry(nscdb, ctx, this_entry); in lookup_int()
1718 (void) mutex_unlock(&nscdb->db_mutex); in lookup_int()
1731 (void) mutex_unlock(&nscdb->db_mutex); in lookup_int()
1746 (void) mutex_unlock(&nscdb->db_mutex); in lookup_int()
1752 (void) mutex_unlock(&nscdb->db_mutex); in lookup_int()
1768 (void) mutex_unlock(&nscdb->db_mutex); in lookup_int()
1775 (void) mutex_unlock(&nscdb->db_mutex); in lookup_int()
1879 getxy_keepalive(nsc_ctx_t *ctx, nsc_db_t *nscdb, int keep, int interval) in getxy_keepalive() argument
1892 (me, "%s: keep alive\n", nscdb->name); in getxy_keepalive()
1900 (void) mutex_lock(&nscdb->db_mutex); in getxy_keepalive()
1901 entry = nscdb->qtail; in getxy_keepalive()
1934 (void) mutex_unlock(&nscdb->db_mutex); in getxy_keepalive()
1943 (void) mutex_unlock(&nscdb->db_mutex); in getxy_keepalive()
1950 (me, "%s: launching update\n", nscdb->name); in getxy_keepalive()
1960 largs->nscdb = nscdb; in getxy_keepalive()
1984 in->nscdb->name, errnum); in launch_update()
2090 delete_entry(nsc_db_t *nscdb, nsc_ctx_t *ctx, nsc_entry_t *entry) in delete_entry() argument
2094 avl_remove(&nscdb->tree, entry); in delete_entry()
2095 HASH_REMOVE(nscdb, entry, hash, nscd_false); in delete_entry()
2096 queue_remove(nscdb, entry); in delete_entry()
2112 nsc_db_t *nscdb; in lookup_cache() local
2121 nscdb = largs->nscdb; in lookup_cache()
2127 if (nscdb->htable) { in lookup_cache()
2128 *entry = hash_find(nscdb, &find_entry, &hash, nscd_true); in lookup_cache()
2130 (void) queue_adjust(nscdb, *entry); in lookup_cache()
2136 *entry = (nsc_entry_t *)avl_find(&nscdb->tree, &find_entry, &pos); in lookup_cache()
2138 (void) queue_adjust(nscdb, *entry); in lookup_cache()
2140 if (nscdb->htable) { in lookup_cache()
2141 if (nscdb->htable[hash] == NULL || in lookup_cache()
2143 nscdb->htable[hash]->stats.hits) { in lookup_cache()
2144 nscdb->htable[hash] = *entry; in lookup_cache()
2185 avl_insert(&nscdb->tree, *entry, pos); /* O(log n) */ in lookup_cache()
2186 (void) queue_adjust(nscdb, *entry); /* constant */ in lookup_cache()
2187 if (nscdb->htable) /* constant */ in lookup_cache()
2188 nscdb->htable[hash] = *entry; in lookup_cache()
2202 node = nscdb->qhead; in lookup_cache()
2206 delete_entry(nscdb, ctx, node); in lookup_cache()
2299 nsc_db_t *nscdb; in reap_cache() local
2311 nscdb = ctx->nsc_db[i]; in reap_cache()
2312 (void) mutex_lock(&nscdb->db_mutex); in reap_cache()
2313 nscdb->reap_node = nscdb->qtail; in reap_cache()
2314 while (nscdb->reap_node != NULL) { in reap_cache()
2316 (void) mutex_unlock(&nscdb->db_mutex); in reap_cache()
2321 (void) mutex_lock(&nscdb->db_mutex); in reap_cache()
2324 if ((node = nscdb->reap_node) == NULL) in reap_cache()
2337 delete_entry(nscdb, ctx, node); in reap_cache()
2340 nscdb->reap_node = node->qnext; in reap_cache()
2345 if (nscdb->htsize == 0) { in reap_cache()
2346 (void) mutex_unlock(&nscdb->db_mutex); in reap_cache()
2358 nentries = avl_numnodes(&nscdb->tree); in reap_cache()
2363 if (nscdb->hash_type == nsc_ht_power2) in reap_cache()
2369 if (nscdb->htsize == newhtsize) { in reap_cache()
2370 (void) mutex_unlock(&nscdb->db_mutex); in reap_cache()
2376 nscdb->name, nscdb->htsize, newhtsize); in reap_cache()
2382 (void) free(nscdb->htable); in reap_cache()
2383 nscdb->htable = calloc(newhtsize, sizeof (*(nscdb->htable))); in reap_cache()
2384 if (nscdb->htable == NULL) { in reap_cache()
2387 nscdb->name); in reap_cache()
2389 nscdb->htsize = -1; in reap_cache()
2391 nscdb->htsize = newhtsize; in reap_cache()
2393 (void) mutex_unlock(&nscdb->db_mutex); in reap_cache()
2429 nscdb = ctx->nsc_db[i]; in reap_cache()
2430 (void) mutex_lock(&nscdb->db_mutex); in reap_cache()
2431 nodes_togo = (value * avl_numnodes(&nscdb->tree)) / 100; in reap_cache()
2434 next_node = nscdb->qhead; in reap_cache()
2441 delete_entry(nscdb, ctx, node); in reap_cache()
2446 (void) mutex_unlock(&nscdb->db_mutex); in reap_cache()