Lines Matching refs:item

51  *	Unless an item destructor has been established, an item
54 * the deletion is holding a read-only lock on the item.
110 * access to an item.
183 * nis_*item() functions, we might as well sanity check
261 * < 0 Exclusive access to item
263 * > 0 Non-exclusive access (read-only) to item
266 * item (__nis_release_item()).
271 __nis_hash_item_mt *item = arg;
275 if (item == 0 || __nis_lock_hash_table(table, 0, "nitmt") == 0)
278 if ((*(pp = __find_item_mt(item->name, table, &key))) != 0) {
283 (void) pthread_cond_init(&item->lock, 0);
284 item->readers = item->writer = 0;
285 item->last_reader_id = item->writer_id = INV_PTHREAD_ID;
287 item->writer = 1;
288 item->writer_id = pthread_self();
291 item->readers = 1;
292 item->last_reader_id = pthread_self();
295 item->next = *pp;
296 *pp = item;
297 item->keychain = key;
300 table->first->prv_item = item;
302 item->nxt_item = table->first;
303 item->prv_item = NULL;
304 table->first = item;
314 __nis_hash_item_mt *item;
319 if ((item = malloc(sizeof (*item))) == 0) {
324 if ((item->name = strdup(name)) == 0) {
326 free(item);
330 if (! __nis_insert_item_mt(item, table, 0)) {
331 free(item->name);
332 free(item);
338 * 0 No access; must not use returned item in any way,
343 * If trylock != 0 and *trylock != 0 and the item exists but the requested
350 __nis_hash_item_mt *item;
359 * The item doesn't exist anymore
369 while ((item = *__find_item_mt(name, table, 0)) != 0) {
371 (item->writer == 0 && item->readers == 0))
373 if (item->writer == 0 && readwrite > 0)
375 if ((item->writer != 0 && item->writer_id == me))
382 (void) pthread_cond_wait(&item->lock, &table->lock);
385 if (item != 0) {
387 if (item->writer == 0) {
388 item->writer_id = me;
391 item->writer++;
393 if (item->readers == 0) {
396 item->last_reader_id = me;
397 item->readers++;
403 return (item);
409 __nis_hash_item_mt *item, *cur, *prev;
415 /* Wait until the first item isn't in use by another thread */
417 while ((item = table->first) != 0) {
420 if (item->readers == 0 && item->writer == 0)
422 if (item->writer != 0 && item->writer_id == mtid)
424 (void) pthread_cond_wait(&item->lock, &table->lock);
428 if (item == 0) {
434 for (cur = table->keys[item->keychain]; cur;
436 if (cur == item) {
452 * We use keychain < 0 to indicate that the item isn't linked
455 item->keychain = -1;
459 (item->writer > 0 || item->readers > 0)) {
468 * Wake up any threads that were waiting for this item. Obviously,
471 (void) pthread_cond_signal(&item->lock);
472 (void) pthread_cond_destroy(&item->lock);
475 * If the item isn't locked, and an item destructor has been
478 if (item->readers == 0 && item->writer == 0 &&
480 (*table->destroyItem)(item);
481 item = 0;
483 item->next = 0;
484 item->prv_item = 0;
485 item->nxt_item = 0;
491 * If we get here, and the 'item' is NULL, we've popped the
492 * item, but also destroyed it. Returning NULL would make
494 * ourselves to pop the next item.
496 return ((item != 0) ? item : __nis_pop_item_mt(table));
508 /* Find the item, and make sure it's not in use */
544 * If this item was locked, we can now decrement the count of
559 * If the item isn't locked, and an item destructor has been
562 * deleted item.
575 * Release an item that had been acquired exclusively or non-exclusively.
583 __nis_hash_item_mt *item = arg;
586 if (item == 0 || __nis_lock_hash_table(table, 0, "nreli") == 0)
589 if ((readwrite < 0 && abs(readwrite) > item->writer) ||
590 (readwrite < 0 && item->writer > 0 &&
591 item->writer_id != pthread_self()) ||
592 (readwrite > 0 && readwrite > item->readers)) {
599 item->writer += readwrite;
600 if (item->writer == 0 && item->keychain >= 0) {
606 item->readers -= readwrite;
607 item->last_reader_id = INV_PTHREAD_ID;
608 if (item->readers == 0 && item->keychain >= 0) {
620 /* Wake up anyone else who wants this item */
621 (void) pthread_cond_signal(&item->lock);
628 if (item->keychain < 0 &&
629 item->readers == 0 && item->writer == 0 &&
630 item->next == 0 &&
631 item->prv_item == 0 && item->nxt_item == 0 &&
633 (*table->destroyItem)(item);
641 * Return -1 if item checked out for both reading and writing, 1 if
647 __nis_hash_item_mt *item = arg;
649 if (item != 0) {
650 if (item->writer > 0) {
651 if (item->writer_id != pthread_self())
654 } else if (item->readers > 0) {