Lines Matching refs:item

269 	__nis_hash_item_mt	*item = arg;  in __nis_insert_item_mt()  local
273 if (item == 0 || __nis_lock_hash_table(table, 0, "nitmt") == 0) in __nis_insert_item_mt()
276 if ((*(pp = __find_item_mt(item->name, table, &key))) != 0) { in __nis_insert_item_mt()
281 (void) pthread_cond_init(&item->lock, 0); in __nis_insert_item_mt()
282 item->readers = item->writer = 0; in __nis_insert_item_mt()
283 item->last_reader_id = item->writer_id = INV_PTHREAD_ID; in __nis_insert_item_mt()
285 item->writer = 1; in __nis_insert_item_mt()
286 item->writer_id = pthread_self(); in __nis_insert_item_mt()
289 item->readers = 1; in __nis_insert_item_mt()
290 item->last_reader_id = pthread_self(); in __nis_insert_item_mt()
293 item->next = *pp; in __nis_insert_item_mt()
294 *pp = item; in __nis_insert_item_mt()
295 item->keychain = key; in __nis_insert_item_mt()
298 table->first->prv_item = item; in __nis_insert_item_mt()
300 item->nxt_item = table->first; in __nis_insert_item_mt()
301 item->prv_item = NULL; in __nis_insert_item_mt()
302 table->first = item; in __nis_insert_item_mt()
312 __nis_hash_item_mt *item; in __nis_insert_name_mt() local
317 if ((item = malloc(sizeof (*item))) == 0) { in __nis_insert_name_mt()
322 if ((item->name = strdup(name)) == 0) { in __nis_insert_name_mt()
324 free(item); in __nis_insert_name_mt()
328 if (! __nis_insert_item_mt(item, table, 0)) { in __nis_insert_name_mt()
329 free(item->name); in __nis_insert_name_mt()
330 free(item); in __nis_insert_name_mt()
348 __nis_hash_item_mt *item; in __nis_find_item_mt() local
367 while ((item = *__find_item_mt(name, table, 0)) != 0) { in __nis_find_item_mt()
369 (item->writer == 0 && item->readers == 0)) in __nis_find_item_mt()
371 if (item->writer == 0 && readwrite > 0) in __nis_find_item_mt()
373 if ((item->writer != 0 && item->writer_id == me)) in __nis_find_item_mt()
380 (void) pthread_cond_wait(&item->lock, &table->lock); in __nis_find_item_mt()
383 if (item != 0) { in __nis_find_item_mt()
385 if (item->writer == 0) { in __nis_find_item_mt()
386 item->writer_id = me; in __nis_find_item_mt()
389 item->writer++; in __nis_find_item_mt()
391 if (item->readers == 0) { in __nis_find_item_mt()
394 item->last_reader_id = me; in __nis_find_item_mt()
395 item->readers++; in __nis_find_item_mt()
401 return (item); in __nis_find_item_mt()
407 __nis_hash_item_mt *item, *cur, *prev; in __nis_pop_item_mt() local
415 while ((item = table->first) != 0) { in __nis_pop_item_mt()
418 if (item->readers == 0 && item->writer == 0) in __nis_pop_item_mt()
420 if (item->writer != 0 && item->writer_id == mtid) in __nis_pop_item_mt()
422 (void) pthread_cond_wait(&item->lock, &table->lock); in __nis_pop_item_mt()
426 if (item == 0) { in __nis_pop_item_mt()
432 for (cur = table->keys[item->keychain]; cur; in __nis_pop_item_mt()
434 if (cur == item) { in __nis_pop_item_mt()
453 item->keychain = -1; in __nis_pop_item_mt()
457 (item->writer > 0 || item->readers > 0)) { in __nis_pop_item_mt()
469 (void) pthread_cond_signal(&item->lock); in __nis_pop_item_mt()
470 (void) pthread_cond_destroy(&item->lock); in __nis_pop_item_mt()
476 if (item->readers == 0 && item->writer == 0 && in __nis_pop_item_mt()
478 (*table->destroyItem)(item); in __nis_pop_item_mt()
479 item = 0; in __nis_pop_item_mt()
481 item->next = 0; in __nis_pop_item_mt()
482 item->prv_item = 0; in __nis_pop_item_mt()
483 item->nxt_item = 0; in __nis_pop_item_mt()
494 return ((item != 0) ? item : __nis_pop_item_mt(table)); in __nis_pop_item_mt()
581 __nis_hash_item_mt *item = arg; in __nis_release_item() local
584 if (item == 0 || __nis_lock_hash_table(table, 0, "nreli") == 0) in __nis_release_item()
587 if ((readwrite < 0 && abs(readwrite) > item->writer) || in __nis_release_item()
588 (readwrite < 0 && item->writer > 0 && in __nis_release_item()
589 item->writer_id != pthread_self()) || in __nis_release_item()
590 (readwrite > 0 && readwrite > item->readers)) { in __nis_release_item()
597 item->writer += readwrite; in __nis_release_item()
598 if (item->writer == 0 && item->keychain >= 0) { in __nis_release_item()
604 item->readers -= readwrite; in __nis_release_item()
605 item->last_reader_id = INV_PTHREAD_ID; in __nis_release_item()
606 if (item->readers == 0 && item->keychain >= 0) { in __nis_release_item()
619 (void) pthread_cond_signal(&item->lock); in __nis_release_item()
626 if (item->keychain < 0 && in __nis_release_item()
627 item->readers == 0 && item->writer == 0 && in __nis_release_item()
628 item->next == 0 && in __nis_release_item()
629 item->prv_item == 0 && item->nxt_item == 0 && in __nis_release_item()
631 (*table->destroyItem)(item); in __nis_release_item()
645 __nis_hash_item_mt *item = arg; in __nis_item_access() local
647 if (item != 0) { in __nis_item_access()
648 if (item->writer > 0) { in __nis_item_access()
649 if (item->writer_id != pthread_self()) in __nis_item_access()
652 } else if (item->readers > 0) { in __nis_item_access()