NAME
Test::AutoBuild::Lock - Manage a lock file to prevent concurrent execution
SYNOPSIS
use Test::AutoBuild::Lock
DESCRIPTION
This module takes out an exclusive lock on a file, preventing multiple instances of the builder running concurrently against the same build home. The scheme to use for locking the file, can be one of flock
, fcntl
, or file
. fcntl
is preferred since it works across NFS. If this isn't supported on the OS running the builder, then flock
should be used. As a last resort the file
method should be used, with does a simple file presence/creation check, although if the builder fails in a bad way it is possible the lock will not be cleaned up correctly.
METHODS
- my $stage = Test::AutoBuild::Lock->new(file => $lock_file_path, method => $lock_method);
-
Creates a new lock manager, for the file specified by the
file
parameter. This should be a fully qualified path for the file to be locked. The file does not have to exist beforehand, but the path must be writable by the user running the build instance. Themethod
parameter should be one of the strings 'fcntl', 'flock' or 'file' designating the method used to acquire the lock. - my $status = $lock->lock;
-
Attempt to acquire the lock, returning a true value if successfull, otherwise a false value to indicate failure (due to the lock being held by another process).
- $lock->unlock;
-
Release a lock previously acquired by the
lock
method. If a lock is not explicitly released, it will be unlocked during garbage collection (via a DESTROY method hook on this object).
AUTHORS
Daniel Berrange <dan@berrange.com> Dennis Gregorovic <dgregorovic@alum.mit.edu>
COPYRIGHT
Copyright (C) 2004 Red Hat, Inc. Copyright (C) 2005 Daniel Berrange.
SEE ALSO
perl(1)
, fcntl(2)
, flock(2)
, Test::AutoBuild