The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.
Changes 05
File-NFSLock.spec 11
META.yml 1021
README 8580
lib/File/NFSLock.pm 15
t/100_load.t 01
t/120_single.t 12
t/200_bl_ex.t 12
t/210_nb_ex.t 12
t/220_ex_scope.t 12
t/230_double.t 12
t/240_fork.t 12
t/300_bl_sh.t 12
t/400_kill.t 12
t/410_die.t 12
t/420_crash.t 12
16 files changed (This is a version diff) 107133
@@ -1,5 +1,10 @@
 Revision history for Perl extension File::NFSLock.
 
+1.22  Jul 26 09:00 2014
+        - Use File::Temp for concurrency compatibility
+          in test suite, such as HARNESS_OPTIONS=j20
+        - Patch RT#86125 and RT#91546
+
 1.21  Jul 13 17:00 2011
         - Various patches by Chorny at cpan dot org
           and fREW frioux at gmail dot com:
@@ -1,7 +1,7 @@
 # Automatically generated by File-NFSLock.spec.PL
 %define class File
 %define subclass NFSLock
-%define version 1.21
+%define version 1.22
 %define release 1
 %define defperlver 5.6.1
 
@@ -1,10 +1,21 @@
-# http://module-build.sourceforge.net/META-spec.html
-#XXXXXXX This is a prototype!!!  It will change in the future!!! XXXXX#
-name:         File-NFSLock
-version:      1.21
-version_from: lib/File/NFSLock.pm
-installdirs:  site
-requires:
-
-distribution_type: module
-generated_by: ExtUtils::MakeMaker version 6.30
+--- #YAML:1.0
+name:               File-NFSLock
+version:            1.22
+abstract:           perl module to do NFS (or not) locking
+author:
+    - Paul Seamons
+license:            unknown
+distribution_type:  module
+configure_requires:
+    ExtUtils::MakeMaker:  0
+build_requires:
+    ExtUtils::MakeMaker:  0
+requires:  {}
+no_index:
+    directory:
+        - t
+        - inc
+generated_by:       ExtUtils::MakeMaker version 6.55_02
+meta-spec:
+    url:      http://module-build.sourceforge.net/META-spec-v1.4.html
+    version:  1.4
@@ -119,122 +119,117 @@ PARAMETERS
         seconds).
 
 METHODS
-        After the $lock object is instantiated with new, as outlined above,
-        some methods may be used for additional functionality.
+    After the $lock object is instantiated with new, as outlined above, some
+    methods may be used for additional functionality.
 
   unlock
-          $lock->unlock;
+      $lock->unlock;
 
-        This method may be used to explicitly release a lock that is
-        aquired. In most cases, it is not necessary to call unlock directly
-        since it will implicitly be called when the object leaves whatever
-        scope it is in.
+    This method may be used to explicitly release a lock that is aquired. In
+    most cases, it is not necessary to call unlock directly since it will
+    implicitly be called when the object leaves whatever scope it is in.
 
   uncache
-          $lock->uncache;
-          $lock->uncache("otherfile1");
-          uncache("otherfile2");
+      $lock->uncache;
+      $lock->uncache("otherfile1");
+      uncache("otherfile2");
 
-        This method is used to freshen up the contents of a file across NFS,
-        ignoring what is contained in the NFS client cache. It is always
-        called from within the new constructor on the file that the lock is
-        being attempted. uncache may be used as either an object method or
-        as a stand alone subroutine.
+    This method is used to freshen up the contents of a file across NFS,
+    ignoring what is contained in the NFS client cache. It is always called
+    from within the new constructor on the file that the lock is being
+    attempted. uncache may be used as either an object method or as a stand
+    alone subroutine.
 
   newpid
-          my $pid = fork;
-          if (defined $pid) {
-            # Fork Failed
-          } elsif ($pid) {
-            $lock->newpid; # Parent
-          } else {
-            $lock->newpid; # Child
-          }
-
-        If fork() is called after a lock has been aquired, then when the
-        lock object leaves scope in either the parent or child, it will be
-        released. This behavior may be inappropriate for your application.
-        To delegate ownership of the lock from the parent to the child, both
-        the parent and child process must call the newpid() method after a
-        successful fork() call. This will prevent the parent from releasing
-        the lock when unlock is called or when the lock object leaves scope.
-        This is also useful to allow the parent to fail on subsequent lock
-        attempts if the child lock is still aquired.
+      my $pid = fork;
+      if (defined $pid) {
+        # Fork Failed
+      } elsif ($pid) {
+        $lock->newpid; # Parent
+      } else {
+        $lock->newpid; # Child
+      }
+
+    If fork() is called after a lock has been aquired, then when the lock
+    object leaves scope in either the parent or child, it will be released.
+    This behavior may be inappropriate for your application. To delegate
+    ownership of the lock from the parent to the child, both the parent and
+    child process must call the newpid() method after a successful fork()
+    call. This will prevent the parent from releasing the lock when unlock
+    is called or when the lock object leaves scope. This is also useful to
+    allow the parent to fail on subsequent lock attempts if the child lock
+    is still aquired.
 
 FAILURE
-        On failure, a global variable, $File::NFSLock::errstr, should be set
-        and should contain the cause for the failure to get a lock. Useful
-        primarily for debugging.
+    On failure, a global variable, $File::NFSLock::errstr, should be set and
+    should contain the cause for the failure to get a lock. Useful primarily
+    for debugging.
 
 LOCK_EXTENSION
-        By default File::NFSLock will use a lock file extenstion of
-        ".NFSLock". This is in a global variable
-        $File::NFSLock::LOCK_EXTENSION that may be changed to suit other
-        purposes (such as compatibility in mail systems).
+    By default File::NFSLock will use a lock file extenstion of ".NFSLock".
+    This is in a global variable $File::NFSLock::LOCK_EXTENSION that may be
+    changed to suit other purposes (such as compatibility in mail systems).
 
 BUGS
-        Notify paul@seamons.com or bbb@cpan.org if you spot anything.
+    Notify paul@seamons.com or bbb@cpan.org if you spot anything.
 
   FIFO
-        Locks are not necessarily obtained on a first come first serve
-        basis. Not only does this not seem fair to new processes trying to
-        obtain a lock, but it may cause a process starvation condition on
-        heavily locked files.
+    Locks are not necessarily obtained on a first come first serve basis.
+    Not only does this not seem fair to new processes trying to obtain a
+    lock, but it may cause a process starvation condition on heavily locked
+    files.
 
   DIRECTORIES
-        Locks cannot be obtained on directory nodes, nor can a directory
-        node be uncached with the uncache routine because hard links do not
-        work with directory nodes. Some other algorithm might be used to
-        uncache a directory, but I am unaware of the best way to do it. The
-        biggest use I can see would be to avoid NFS cache of directory
-        modified and last accessed timestamps.
+    Locks cannot be obtained on directory nodes, nor can a directory node be
+    uncached with the uncache routine because hard links do not work with
+    directory nodes. Some other algorithm might be used to uncache a
+    directory, but I am unaware of the best way to do it. The biggest use I
+    can see would be to avoid NFS cache of directory modified and last
+    accessed timestamps.
 
 INSTALL
-        Download and extract tarball before running these commands in its
-        base directory:
+    Download and extract tarball before running these commands in its base
+    directory:
 
-          perl Makefile.PL
-          make
-          make test
-          make install
+      perl Makefile.PL
+      make
+      make test
+      make install
 
-        For RPM installation, download tarball before running these commands
-        in your _topdir:
+    For RPM installation, download tarball before running these commands in
+    your _topdir:
 
-          rpm -ta SOURCES/File-NFSLock-*.tar.gz
-          rpm -ih RPMS/noarch/perl-File-NFSLock-*.rpm
+      rpm -ta SOURCES/File-NFSLock-*.tar.gz
+      rpm -ih RPMS/noarch/perl-File-NFSLock-*.rpm
 
 AUTHORS
-        Paul T Seamons (paul@seamons.com) - Performed majority of the
-        programming with copious amounts of input from Rob Brown.
+    Paul T Seamons (paul@seamons.com) - Performed majority of the
+    programming with copious amounts of input from Rob Brown.
 
-        Rob B Brown (bbb@cpan.org) - In addition to helping in the
-        programming, Rob Brown provided most of the core testing to make
-        sure implementation worked properly. He is now the current
-        maintainer.
+    Rob B Brown (bbb@cpan.org) - In addition to helping in the programming,
+    Rob Brown provided most of the core testing to make sure implementation
+    worked properly. He is now the current maintainer.
 
-        Also Mark Overmeer (mark@overmeer.net) - Author of
-        Mail::Box::Locker, from which some key concepts for File::NFSLock
-        were taken.
+    Also Mark Overmeer (mark@overmeer.net) - Author of Mail::Box::Locker,
+    from which some key concepts for File::NFSLock were taken.
 
-        Also Kevin Johnson (kjj@pobox.com) - Author of
-        Mail::Folder::Maildir, from which Mark Overmeer based
-        Mail::Box::Locker.
+    Also Kevin Johnson (kjj@pobox.com) - Author of Mail::Folder::Maildir,
+    from which Mark Overmeer based Mail::Box::Locker.
 
 COPYRIGHT
-          Copyright (C) 2001
-          Paul T Seamons
-          paul@seamons.com
-          http://seamons.com/
+      Copyright (C) 2001
+      Paul T Seamons
+      paul@seamons.com
+      http://seamons.com/
 
-          Copyright (C) 2002-2003,
-          Rob B Brown
-          bbb@cpan.org
+      Copyright (C) 2002-2003,
+      Rob B Brown
+      bbb@cpan.org
 
-          This package may be distributed under the terms of either the
-          GNU General Public License
-            or the
-          Perl Artistic License
+      This package may be distributed under the terms of either the
+      GNU General Public License
+        or the
+      Perl Artistic License
 
-          All rights reserved.
+      All rights reserved.
 
@@ -32,7 +32,7 @@ our $errstr;
 use base 'Exporter';
 our @EXPORT_OK = qw(uncache);
 
-our $VERSION = '1.21';
+our $VERSION = '1.22';
 
 #Get constants, but without the bloat of
 #use Fcntl qw(LOCK_SH LOCK_EX LOCK_NB);
@@ -486,6 +486,8 @@ sub newpid {
 1;
 
 
+=pod
+
 =head1 NAME
 
 File::NFSLock - perl module to do NFS (or not) locking
@@ -621,6 +623,8 @@ recursion load could exist so do_lock will only recurse 10 times (this is only
 a problem if the stale_lock_timeout is set too low -- on the order of one or two
 seconds).
 
+=back
+
 =head1 METHODS
 
 After the $lock object is instantiated with new,
@@ -6,5 +6,6 @@ use strict;
 use warnings;
 
 use Test::More tests => 1;
+use File::Temp qw(tempfile);
 
 use_ok 'File::NFSLock';
@@ -3,8 +3,9 @@
 use Test::More tests => 2;
 use File::NFSLock;
 use Fcntl qw(O_CREAT O_RDWR O_RDONLY O_TRUNC LOCK_EX);
+use File::Temp qw(tempfile);
 
-my $datafile = "testfile.dat";
+my $datafile = tempfile();
 
 # Create a blank file
 sysopen ( my $fh, $datafile, O_CREAT | O_RDWR | O_TRUNC );
@@ -2,6 +2,7 @@
 
 use strict;
 use warnings;
+use File::Temp qw(tempfile);
 
 use Test::More;
 if( $^O eq 'MSWin32' ) {
@@ -19,7 +20,7 @@ my $n = 50;
 
 $| = 1; # Buffer must be autoflushed because of fork() below.
 
-my $datafile = "testfile.dat";
+my $datafile = tempfile();
 
 # Create a blank file
 sysopen ( my $fh, $datafile, O_CREAT | O_RDWR | O_TRUNC );
@@ -1,5 +1,6 @@
 use strict;
 use warnings;
+use File::Temp qw(tempfile);
 
 # Non-Blocking Exclusive Lock Test
 
@@ -9,7 +10,7 @@ use Fcntl qw(O_CREAT O_RDWR O_RDONLY O_TRUNC LOCK_EX LOCK_NB);
 
 $| = 1; # Buffer must be autoflushed because of fork() below.
 
-my $datafile = "testfile.dat";
+my $datafile = tempfile();
 
 # Create a blank file
 sysopen ( my $fh, $datafile, O_CREAT | O_RDWR | O_TRUNC );
@@ -11,6 +11,7 @@
 
 use strict;
 use warnings;
+use File::Temp qw(tempfile);
 
 use Test::More;
 if( $^O eq 'MSWin32' ) {
@@ -24,7 +25,7 @@ use Fcntl qw(O_CREAT O_RDWR O_RDONLY O_TRUNC LOCK_EX LOCK_NB);
 
 $| = 1; # Buffer must be autoflushed because of fork() below.
 
-my $datafile = "testfile.dat";
+my $datafile = tempfile();
 
 # Create a blank file
 sysopen ( my $fh, $datafile, O_CREAT | O_RDWR | O_TRUNC );
@@ -5,6 +5,7 @@
 
 use strict;
 use warnings;
+use File::Temp qw(tempfile);
 
 use Test::More tests => 5;
 use File::NFSLock;
@@ -12,7 +13,7 @@ use Fcntl qw(O_CREAT O_RDWR O_RDONLY O_TRUNC O_APPEND LOCK_EX LOCK_SH LOCK_NB);
 
 $| = 1;
 
-my $datafile = "testfile.dat";
+my $datafile = tempfile();
 
 # Wipe lock file in case it exists
 unlink ("$datafile$File::NFSLock::LOCK_EXTENSION");
@@ -5,6 +5,7 @@
 
 use strict;
 use warnings;
+use File::Temp qw(tempfile);
 
 use Test::More tests => 5;
 use File::NFSLock;
@@ -12,7 +13,7 @@ use Fcntl qw(O_CREAT O_RDWR O_RDONLY O_TRUNC O_APPEND LOCK_EX LOCK_SH LOCK_NB);
 
 $| = 1; # Buffer must be autoflushed because of fork() below.
 
-my $datafile = "testfile.dat";
+my $datafile = tempfile();
 
 # Wipe lock file in case it exists
 unlink ("$datafile$File::NFSLock::LOCK_EXTENSION");
@@ -1,6 +1,7 @@
 # Blocking Shared Lock Test
 use strict;
 use warnings;
+use File::Temp qw(tempfile);
 
 use Test::More;
 if( $^O eq 'MSWin32' ) {
@@ -18,7 +19,7 @@ my $shared_delay = 5;
 
 $| = 1; # Buffer must be autoflushed because of fork() below.
 
-my $datafile = "testfile.dat";
+my $datafile = tempfile();
 
 # Create a blank file
 sysopen ( my $fh, $datafile, O_CREAT | O_RDWR | O_TRUNC );
@@ -2,6 +2,7 @@
 
 use strict;
 use warnings;
+use File::Temp qw(tempfile);
 
 use Test::More tests => 10;
 use File::NFSLock;
@@ -9,7 +10,7 @@ use Fcntl qw(O_CREAT O_RDWR O_RDONLY O_TRUNC LOCK_EX);
 
 $| = 1; # Buffer must be autoflushed because of fork() below.
 
-my $datafile = "testfile.dat";
+my $datafile = tempfile();
 
 # Wipe lock file in case it exists
 unlink ("$datafile$File::NFSLock::LOCK_EXTENSION");
@@ -2,6 +2,7 @@
 
 use strict;
 use warnings;
+use File::Temp qw(tempfile);
 
 use Test::More tests => 9;
 use File::NFSLock;
@@ -9,7 +10,7 @@ use Fcntl qw(O_CREAT O_RDWR O_RDONLY O_TRUNC LOCK_EX);
 
 $| = 1; # Buffer must be autoflushed because of fork() below.
 
-my $datafile = "testfile.dat";
+my $datafile = tempfile();
 
 # Wipe lock file in case it exists
 unlink ("$datafile$File::NFSLock::LOCK_EXTENSION");
@@ -2,6 +2,7 @@
 
 use strict;
 use warnings;
+use File::Temp qw(tempfile);
 
 use Test::More tests => 10;
 use File::NFSLock;
@@ -9,7 +10,7 @@ use Fcntl qw(O_CREAT O_RDWR O_RDONLY O_TRUNC LOCK_EX);
 
 $| = 1; # Buffer must be autoflushed because of fork() below.
 
-my $datafile = "testfile.dat";
+my $datafile = tempfile();
 
 # Wipe lock file in case it exists
 unlink ("$datafile$File::NFSLock::LOCK_EXTENSION");