safelock.c
/* Remove a safelock lock file.
 *
 * Use the "removed" flag to ensure only the first attempt removes
 * the actual file.
 *
 * Any further attempts to use the safelock will return EINVAL
 * indicating the safelock needs to be re-opened.
 *
 * Note: This doesn't inform the current owner that the lock
 * has been invalidated.
 */
Remove a safelock lock file.
Use the "removed" flag to ensure only the first attempt removes
the actual file.

Any further attempts to use the safelock will return EINVAL
indicating the safelock needs to be re-opened.

This doesn't inform the current owner that the lock
has been invalidated.
Remove a safelock lock file . Use the " removed " flag to ensure only the first attempt removes the actual file . Any further attempts to use the safelock will return EINVAL indicating the safelock needs to be re - opened . This doesn ' t inform the current owner that the lock has been invalidated .
int safelock_remove(safelock_t lock)
{
    int ret, err;
    assert(lock && lock->shared);
    err = data_mutex_lock(lock, NULL);
    if (err == EINVAL)
        return 0;   
    if (err)
        return err;
    ret = unlink(lock->filename);
    if (ret < 0) {
        err = errno;
    } else {
        lock->shared->removed = 1;
        err = 0;
    }
    NOFAIL(pthread_mutex_unlock(&lock->shared->data_mutex));
    return err;
}
int safelock_remove ( safelock_t lock ) { int ret , err ; assert ( lock && lock -> shared ) ; err = data_mutex_lock ( lock , NULL ) ; if ( err == EINVAL ) return 0 ; if ( err ) return err ; ret = unlink ( lock -> filename ) ; if ( ret < 0 ) { err = errno ; } else { lock -> shared -> removed = 1 ; err = 0 ; } NOFAIL ( pthread_mutex_unlock ( & lock -> shared -> data_mutex ) ) ; return err ; }
Remove a safelock lock file.
Remove a safelock lock file .
/* Already removed by another thread */ /* Attempt to remove the safelock first. If unlink fails,
     * the safelock won't be tagged as "removed". */