netatalk  4.6.0
Free and Open Source Apple Filing Protocol (AFP) Server
Loading...
Searching...
No Matches
peer_lock.h File Reference
#include <sys/types.h>

Go to the source code of this file.

Data Structures

struct  peer

Functions

int peer_hold_lock (struct peer *p, const char *path, short type, off_t start, off_t len)
 Fork a peer that holds an fcntl lock until released.
void peer_release (struct peer *p)
 Release a held peer lock and reap the peer.
int peer_try_lock (const char *path, short type, off_t start, off_t len)
 Probe a lock range from a forked child.

Function Documentation

◆ peer_hold_lock()

int peer_hold_lock ( struct peer * p,
const char * path,
short type,
off_t start,
off_t len )
extern

Fork a peer that holds an fcntl lock until released.

F_SETLK/F_GETLK never conflict with or report the calling process's own locks, so a test that needs a genuinely contending lock forks a peer that takes it and parks.

Parameters
[out]pfilled with the peer's pid and control pipes
[in]pathfile to lock
[in]typeF_RDLCK or F_WRLCK
[in]startfirst byte of the range
[in]lenrange length (0 = to EOF)
Returns
0 with the lock held by the time this returns, -1 on failure

◆ peer_release()

void peer_release ( struct peer * p)
extern

Release a held peer lock and reap the peer.

Parameters
[in]ppeer filled by peer_hold_lock()

◆ peer_try_lock()

int peer_try_lock ( const char * path,
short type,
off_t start,
off_t len )
extern

Probe a lock range from a forked child.

Cross-process, so it sees locks this process holds (which its own F_GETLK never would).

Parameters
[in]pathfile to probe
[in]typeF_RDLCK or F_WRLCK
[in]startfirst byte of the range
[in]lenrange length (0 = to EOF)
Returns
1 if the lock was acquired (range free), 0 if it conflicted (range held by another process), -1 on a fork/open error