safelock.c
/* Lock "data_mutex" and detect whether the safelock has been removed.
 *
 * Used when the caller intends to lock "owner_mutex" */
Lock "data_mutex" and detect whether the safelock has been removed.
Used when the caller intends to lock "owner_mutex"
Lock " data_mutex " and detect whether the safelock has been removed . Used when the caller intends to lock " owner_mutex "
static int data_mutex_lock(safelock_t lock, int *dirty)
{
    lock_data_t *shared;
    int err;
    assert(lock);
    assert(lock->shared);
    shared = lock->shared;
    err = mutex_lock(&shared->data_mutex, SAFELOCK_LOCK_WAIT, dirty);
    if (err) {
        assert(err != EDEADLK); 
        return err;
    }
    if (shared->removed) {
        NOFAIL(pthread_mutex_unlock(&shared->data_mutex));
        return EINVAL;
    }
    return 0;
}
static int data_mutex_lock ( safelock_t lock , int * dirty ) { lock_data_t * shared ; int err ; assert ( lock ) ; assert ( lock -> shared ) ; shared = lock -> shared ; err = mutex_lock ( & shared -> data_mutex , SAFELOCK_LOCK_WAIT , dirty ) ; if ( err ) { assert ( err != EDEADLK ) ; return err ; } if ( shared -> removed ) { NOFAIL ( pthread_mutex_unlock ( & shared -> data_mutex ) ) ; return EINVAL ; } return 0 ; }
Lock "data_mutex" and detect whether the safelock has been removed.
Lock " data_mutex " and detect whether the safelock has been removed .
/* BUG: Locked twice within 1 thread.. */ /* dead safelock - return EINVAL to advise the
         * caller the safelock should be re-opened. */