/[autoconf]/autoconf/lib/Autom4te/XFile.pm
ViewVC logotype

Diff of /autoconf/lib/Autom4te/XFile.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

--- autoconf/lib/Autom4te/XFile.pm	2003/09/13 22:00:36	1.8
+++ autoconf/lib/Autom4te/XFile.pm	2003/10/09 20:23:54	1.11
@@ -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 Autom4te::ChannelDefs;
@@ -216,10 +217,21 @@ 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, by inspecting MAKEFLAGS and looking for
+  # any arguments indicating that the invoker used -j.
+  # Admittedly this is a bit of a hack.
+  if (!flock ($fh, $mode)
+      && (!$!{ENOLCK}
+	  || " -$ENV{'MAKEFLAGS'}" =~ / (-[BdeikrRsSw]*j|---?jobs)/))
     {
       my $file = $fh->name;
-      fatal "cannot lock $file with mode $mode: $!";
+      fatal "cannot lock $file with mode $mode (perhaps you are running make -j on a lame NFS client?): $!";
     }
 }
 

 

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26