NAME

Qmail::Control::Lock - Perl extension for locking Qmail's control file subsystem.

SYNOPSIS

use Qmail::Control::Lock;

my $lock = Qmail::Control::Lock->new();

# Get a shared lock on the control subsystem. 
$lock->lock_shared() or die "Couldn't get sh lock: $!\n";

# Get an exclusive lock on the control subsystem. 
$lock2->lock_exclusive() or die "Couldn't get ex lock: $!\n";

# Change a shared lock to an exclusive lock.
$lock->relock('exclusive') or die "Couldn't change sh to ex lock: $!\n";

# Unlock the control subsystem.
$lock->unlock();
$lock2->unlock();

DESCRIPTION

Qmail::Control::Lock provides and interface for locking Qmail's control file subsystem.

Dan Bernstein does not endorse this module or this locking method, and as far as I know, only Qmail::Control::Lock uses it.

EXPORTS

None by default.

METHODS

Qmail::Control::Lock->new()

Creates a new Qmail::Control::Lock object.

Returns a reference to the newly created object.

Takes no arguments, currently. This may change, but the argumentless form will always exist.

$lock->lock_shared();

Gets a shared lock on the Qmail control file subsystem.

Returns true on success or undef on a serious error.

Takes no arguments.

$lock->lock_exclusive();

Gets an exclusive lock on the Qmail control file subsystem.

Returns true on success or undef on a serious error.

Takes no arguments.

$lock->relock();

Changes one type of lock (either shared or exclusive) into another.

Returns true on success or undef on a serious error.

Takes a single argument, either 'shared' or 'exclusive', which indicates which type of lock to engage. If you pass 'shared', and the lock is already 'shared', this is a no-op.

$lock->unlock();

Unlocks the Qmail control file subsystem.

Returns nothing.

Takes no arguments.

AUTHOR

Paul Prince, <princep@charter.net>

SEE ALSO

perl. Qmail::Control::Lock.