* lib/Automake/XFile.pm: Use Errno.
authorAkim Demaille <akim@epita.fr>
Wed, 1 Oct 2003 07:14:32 +0000 (07:14 +0000)
committerAkim Demaille <akim@epita.fr>
Wed, 1 Oct 2003 07:14:32 +0000 (07:14 +0000)
(lock): Ignore ENOLCK errors.  Problem reported Andreas Schwab in
<http://mail.gnu.org/archive/html/bug-autoconf/2003-09/msg00141.html>.

ChangeLog
lib/Automake/XFile.pm

index c8e579b..d4de592 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2003-10-01  Paul Eggert  <eggert@twinsun.com>
+
+       * lib/Automake/XFile.pm: Use Errno.
+       (lock): Ignore ENOLCK errors.  Problem reported Andreas Schwab in
+       <http://mail.gnu.org/archive/html/bug-autoconf/2003-09/msg00141.html>.
+
 2003-09-30  Tom Tromey  <tromey@redhat.com>
 
        * lib/Automake/Options.pm (_process_option_list): Recognize
index c2b3e63..8c719e3 100644 (file)
@@ -87,6 +87,7 @@ require 5.000;
 use strict;
 use vars qw($VERSION @EXPORT @EXPORT_OK $AUTOLOAD @ISA);
 use Carp;
+use Errno;
 use IO::File;
 use File::Basename;
 use Automake::ChannelDefs;
@@ -216,7 +217,15 @@ sub lock
 {
   my ($fh, $mode) = @_;
   # Cannot use @_ here.
-  if (!flock ($fh, $mode))
+
+  # On some systems (e.g. GNU/Linux with NFSv2), flock(2) does not work over
+  # NFS, but Perl prefers that over fcntl(2) if it exists and if
+  # perl was not built with -Ud_flock.  Normally, this problem is harmless,
+  # so ignore the ENOLCK errors that are reported in that situation,
+  # However, if the invoker is using "make -j", the problem is not harmless,
+  # so report it in that case.  Admittedly this is a bit of a hack.
+  if (!flock ($fh, $mode)
+      && (!$!{ENOLCK} || " $ENV{'MAKEFLAGS'}" =~ / (-j|--jobs)/))
     {
       my $file = $fh->name;
       fatal "cannot lock $file with mode $mode: $!";