Lines Matching refs:item
271 __nis_hash_item_mt *item = arg; in __nis_insert_item_mt() local
275 if (item == 0 || __nis_lock_hash_table(table, 0, "nitmt") == 0) in __nis_insert_item_mt()
278 if ((*(pp = __find_item_mt(item->name, table, &key))) != 0) { in __nis_insert_item_mt()
283 (void) pthread_cond_init(&item->lock, 0); in __nis_insert_item_mt()
284 item->readers = item->writer = 0; in __nis_insert_item_mt()
285 item->last_reader_id = item->writer_id = INV_PTHREAD_ID; in __nis_insert_item_mt()
287 item->writer = 1; in __nis_insert_item_mt()
288 item->writer_id = pthread_self(); in __nis_insert_item_mt()
291 item->readers = 1; in __nis_insert_item_mt()
292 item->last_reader_id = pthread_self(); in __nis_insert_item_mt()
295 item->next = *pp; in __nis_insert_item_mt()
296 *pp = item; in __nis_insert_item_mt()
297 item->keychain = key; in __nis_insert_item_mt()
300 table->first->prv_item = item; in __nis_insert_item_mt()
302 item->nxt_item = table->first; in __nis_insert_item_mt()
303 item->prv_item = NULL; in __nis_insert_item_mt()
304 table->first = item; in __nis_insert_item_mt()
314 __nis_hash_item_mt *item; in __nis_insert_name_mt() local
319 if ((item = malloc(sizeof (*item))) == 0) { in __nis_insert_name_mt()
324 if ((item->name = strdup(name)) == 0) { in __nis_insert_name_mt()
326 free(item); in __nis_insert_name_mt()
330 if (! __nis_insert_item_mt(item, table, 0)) { in __nis_insert_name_mt()
331 free(item->name); in __nis_insert_name_mt()
332 free(item); in __nis_insert_name_mt()
350 __nis_hash_item_mt *item; in __nis_find_item_mt() local
369 while ((item = *__find_item_mt(name, table, 0)) != 0) { in __nis_find_item_mt()
371 (item->writer == 0 && item->readers == 0)) in __nis_find_item_mt()
373 if (item->writer == 0 && readwrite > 0) in __nis_find_item_mt()
375 if ((item->writer != 0 && item->writer_id == me)) in __nis_find_item_mt()
382 (void) pthread_cond_wait(&item->lock, &table->lock); in __nis_find_item_mt()
385 if (item != 0) { in __nis_find_item_mt()
387 if (item->writer == 0) { in __nis_find_item_mt()
388 item->writer_id = me; in __nis_find_item_mt()
391 item->writer++; in __nis_find_item_mt()
393 if (item->readers == 0) { in __nis_find_item_mt()
396 item->last_reader_id = me; in __nis_find_item_mt()
397 item->readers++; in __nis_find_item_mt()
403 return (item); in __nis_find_item_mt()
409 __nis_hash_item_mt *item, *cur, *prev; in __nis_pop_item_mt() local
417 while ((item = table->first) != 0) { in __nis_pop_item_mt()
420 if (item->readers == 0 && item->writer == 0) in __nis_pop_item_mt()
422 if (item->writer != 0 && item->writer_id == mtid) in __nis_pop_item_mt()
424 (void) pthread_cond_wait(&item->lock, &table->lock); in __nis_pop_item_mt()
428 if (item == 0) { in __nis_pop_item_mt()
434 for (cur = table->keys[item->keychain]; cur; in __nis_pop_item_mt()
436 if (cur == item) { in __nis_pop_item_mt()
455 item->keychain = -1; in __nis_pop_item_mt()
459 (item->writer > 0 || item->readers > 0)) { in __nis_pop_item_mt()
471 (void) pthread_cond_signal(&item->lock); in __nis_pop_item_mt()
472 (void) pthread_cond_destroy(&item->lock); in __nis_pop_item_mt()
478 if (item->readers == 0 && item->writer == 0 && in __nis_pop_item_mt()
480 (*table->destroyItem)(item); in __nis_pop_item_mt()
481 item = 0; in __nis_pop_item_mt()
483 item->next = 0; in __nis_pop_item_mt()
484 item->prv_item = 0; in __nis_pop_item_mt()
485 item->nxt_item = 0; in __nis_pop_item_mt()
496 return ((item != 0) ? item : __nis_pop_item_mt(table)); in __nis_pop_item_mt()
583 __nis_hash_item_mt *item = arg; in __nis_release_item() local
586 if (item == 0 || __nis_lock_hash_table(table, 0, "nreli") == 0) in __nis_release_item()
589 if ((readwrite < 0 && abs(readwrite) > item->writer) || in __nis_release_item()
590 (readwrite < 0 && item->writer > 0 && in __nis_release_item()
591 item->writer_id != pthread_self()) || in __nis_release_item()
592 (readwrite > 0 && readwrite > item->readers)) { in __nis_release_item()
599 item->writer += readwrite; in __nis_release_item()
600 if (item->writer == 0 && item->keychain >= 0) { in __nis_release_item()
606 item->readers -= readwrite; in __nis_release_item()
607 item->last_reader_id = INV_PTHREAD_ID; in __nis_release_item()
608 if (item->readers == 0 && item->keychain >= 0) { in __nis_release_item()
621 (void) pthread_cond_signal(&item->lock); in __nis_release_item()
628 if (item->keychain < 0 && in __nis_release_item()
629 item->readers == 0 && item->writer == 0 && in __nis_release_item()
630 item->next == 0 && in __nis_release_item()
631 item->prv_item == 0 && item->nxt_item == 0 && in __nis_release_item()
633 (*table->destroyItem)(item); in __nis_release_item()
647 __nis_hash_item_mt *item = arg; in __nis_item_access() local
649 if (item != 0) { in __nis_item_access()
650 if (item->writer > 0) { in __nis_item_access()
651 if (item->writer_id != pthread_self()) in __nis_item_access()
654 } else if (item->readers > 0) { in __nis_item_access()