NAME

IPC::Locker - Distributed lock handler

SYNOPSIS

  use IPC::Locker;

  my $lock = IPC::Locker->lock(lock=>'one_per_machine',
				  host=>'example.std.com',
				  port=>223);

  if ($lock->lock()) { something; }
  if ($lock->locked()) { something; }

  $lock->unlock();

DESCRIPTION

IPC::Locker will query a remote server to obtain a lock. This is useful for distributed utilities which run on many machines, and cannot use file locks or other such mechanisms due to NFS or lack of common file systems.

new ([parameter=>value ...]);

Create a lock structure.

lock ([parameter=>value ...]);

Try to obtain the lock, return the lock object if successful, else undef.

locked ()

Return true if the lock has been obtained.

unlock ()

Remove the given lock. This will be called automatically when the object is destroyed.

break_lock ()

Remove current locker for the given lock.

owner ([parameter=>value ...]);

Returns a string of who has the lock or undef if not currently . Note that this information is not atomic, and may change asyncronously; do not use this to tell if the lock will be available, to do that, try to obtain the lock and then release it if you got it.

PARAMETERS

block

Boolean flag, true indicates wait for the lock when calling lock() and die if a error occurs. False indicates to just return false. Defaults to true.

host

The name of the host containing the lock server.

port

The port number of the lock server. Defaults to 1751.

A function to print a message when the lock is broken. The only argument is self. Defaults to print a message if verbose is set.

A function to print a message when the lock is obtained after a delay. The only argument is self. Defaults to print a message if verbose is set.

A function to print a message when the lock is busy and needs to be waited for. The first argument is self, second the name of the lock. Defaults to print a message if verbose is set.

timeout

The maximum time in seconds that the lock may be held before being forced open, passed to the server when the lock is created. Thus if the requestor dies, the lock will be released after that amount of time. Defaults to 10 minutes.

user

Name to request the lock under, defaults to host_pid_user

verbose

True to print messages when waiting for locks. Defaults false.

SEE ALSO

lockerd,

DISTRIBUTION

This package is distributed via CPAN.

AUTHORS

Wilson Snyder <wsnyder@ultranet.com>

3 POD Errors

The following errors were encountered while parsing the POD:

Around line 78:

You forgot a '=back' before '=head1'

Around line 80:

'=item' outside of any '=over'

Around line 125:

You forgot a '=back' before '=head1'