src/lib/rwlock.c
int rwl_readtrylock(brwlock_t *rwl)
{
   int stat, stat2;

   if (rwl->valid != RWLOCK_VALID) {
      return EINVAL;
   }
   if ((stat = pthread_mutex_lock(&rwl->mutex)) != 0) {
      return stat;
   }
   if (rwl->w_active) {
      stat = EBUSY;
   } else {
      rwl->r_active++;                /* we are running */
   }
   stat2 = pthread_mutex_unlock(&rwl->mutex);
   return (stat == 0 ? stat2 : stat);
}
/*
 * Attempt to lock for read access, don't wait
 */
Attempt to lock for read access, don't wait
Attempt to lock for read access don ' t wait
int rwl_readtrylock(brwlock_t *rwl)
{
   int stat, stat2;
   if (rwl->valid != RWLOCK_VALID) {
      return EINVAL;
   }
   if ((stat = pthread_mutex_lock(&rwl->mutex)) != 0) {
      return stat;
   }
   if (rwl->w_active) {
      stat = EBUSY;
   } else {
      rwl->r_active++;                
   }
   stat2 = pthread_mutex_unlock(&rwl->mutex);
   return (stat == 0 ? stat2 : stat);
}
int rwl_readtrylock ( brwlock_t * rwl ) { int stat , stat2 ; if ( rwl -> valid != RWLOCK_VALID ) { return EINVAL ; } if ( ( stat = pthread_mutex_lock ( & rwl -> mutex ) ) != 0 ) { return stat ; } if ( rwl -> w_active ) { stat = EBUSY ; } else { rwl -> r_active ++ ; } stat2 = pthread_mutex_unlock ( & rwl -> mutex ) ; return ( stat == 0 ? stat2 : stat ) ; }
Attempt to lock for read access, don't wait
Attempt to lock for read access don ' t wait
/* we are running */