safelock.c
/* Atomically update the Safelock custom data */
Atomically update the Safelock custom data
Atomically update the Safelock custom data
int safelock_update_data(safelock_t lock, int data)
{
    int err;
    assert(lock);
    assert(lock->shared);
    if (!lock->locked)
        return EPERM;
    err = data_mutex_lock(lock, NULL);
    if (err)
        return err;
    lock->shared->data = data;
    NOFAIL(pthread_mutex_unlock(&lock->shared->data_mutex));
    return 0;
}
int safelock_update_data ( safelock_t lock , int data ) { int err ; assert ( lock ) ; assert ( lock -> shared ) ; if ( ! lock -> locked ) return EPERM ; err = data_mutex_lock ( lock , NULL ) ; if ( err ) return err ; lock -> shared -> data = data ; NOFAIL ( pthread_mutex_unlock ( & lock -> shared -> data_mutex ) ) ; return 0 ; }
Atomically update the Safelock custom data
Atomically update the Safelock custom data
/* Only allow the current owner to update the lock data. This helps
     * to guarantee that the lock data is consistent unless both
     * data_mutex and owner_mutex report EOWNERDEAD. */