DLM-Client

 view release on metacpan or  search on metacpan

lib/DLM/Client.pm  view on Meta::CPAN

=head1 SYNOPSIS

    use DLM::Client qw/LKM_EXMODE/;
    my $lock_id = 0;

    if ( DLM::Client::lock_resource( 'LOCK_NAME', LKM_EXMODE, 0, $lock_id) == 0 ){
        print "Locked\n";
    }

    if ( DLM::Client::unlock_resource($lock_id) == 0 ) {
        print "Unlocked\n";
    }

=head1 DESCRIPTION

DLM::Client is a direct binding to linux distributed lock manager (DLM is part of the Linux kernel from version 2.6.19) from RedHat.

It is extremely fast and really distributed but you should configure DLM cluster before.

=head1 DLM OVERVIEW

lib/DLM/Client.pm  view on Meta::CPAN

    LKF_QUECVT             Add conversion to the back of the convert queue - only valid for some convert operations
    LKF_PERSISTENT Don't automatically unlock this lock when the process exits (must be root).

=head3 Return codes:

    0 is returned if the call completed successfully. If not, -1 is returned and $! is set to one of the
    following:
    EINVAL                  An invalid parameter was passed to the call (eg bad lock mode or flag)
    ENOMEM                  A (kernel) memory allocation failed
    EAGAIN                  LKF_NOQUEUE was requested and the lock could not be granted
    EBUSY  The lock is currently being locked or converted
    EFAULT The userland buffer could not be read/written by the kernel (this indicates a library problem)

=head2 unlock_resource($lockid);

      Unlocks the resource.

=head3 Return codes:

      0 is returned if the call completed successfully. If not, -1 is returned and errno is set to one of the
      following:
      EINVAL                  An invalid parameter was passed to the call (eg bad lock mode or flag)
      EINPROGRESS             The lock is already being unlocked
      EBUSY                   The lock is currently being locked or converted

=head2 Example
     
      my $lockid;
      my $status = lock_resource("mylock", LKM_EXMODE, 0, $lockid);
      
      if ($status == 0) { 
          $status = unlock_resource($lockid)
      }



( run in 0.434 second using v1.01-cache-2.11-cpan-49f99fa48dc )