[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: FreeBSD, autom4te and locking on NFS

From: Noah Misch
Subject: Re: FreeBSD, autom4te and locking on NFS
Date: Fri, 28 Apr 2006 20:35:01 -0700
User-agent: Mutt/1.5.6i

Hi Ralf,

On Fri, Apr 28, 2006 at 11:52:58AM +0200, Ralf Wildenhues wrote:
> - XFile.pm needs a copyright year update (which I can add, when given
>   OK-to-commit).

Thanks; I added that.

> - AFAICS this causes autom4te to continue but exit with an error status.

You are correct, but I did not intend to make it do that.  We need to use a
warning class, not an error.  I chose `unsupported'.

>   The only difference with parallel make is that the message is
>   adjusted.  Is that correct semantics?  Wouldn't it be safer to
>   actually fatal() if we are running under parallel make?
>   (Take this with a grain of salt; I don't know what I'm talking about.)

Good question; yes.  I have changed the patch to do that.  Of the luxuries of
`make -j' and broken locking, users may now pick one.

I also tried to improve the added message.

> - BTW, is there real-world indication of build tools other than
>   Automake-created Makefiles that may happen to invoke parallel autom4te
>   instances, possibly indirectly?

By appearances, the sample makefile content in documentation node `Automatic
Remaking' can run autoconf and autoheader in parallel.  I do not know how many
people have copied it.

Here is an updated patch.  What do you think?

2006-04-28  Noah Misch  <address@hidden>

        * lib/Autom4te/XFile.pm (lock): Allow EOPNOTSUPP, besides ENOLCK.  Only
        mention `make -j' when applicable.  Only raise fatal errors when `make
        -j' is involved.  Improve error message.

diff -Nurp -X dontdiff ac-clean/lib/Autom4te/XFile.pm 
--- ac-clean/lib/Autom4te/XFile.pm      2005-05-14 03:00:39.000000000 -0400
+++ ac-xfile_lock/lib/Autom4te/XFile.pm 2006-04-28 23:23:25.000000000 -0400
@@ -1,4 +1,4 @@
-# Copyright (C) 2001, 2003, 2004 Free Software Foundation, Inc.
+# Copyright (C) 2001, 2003, 2004, 2006 Free Software Foundation, Inc.
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -91,6 +91,7 @@ use Errno;
 use IO::File;
 use File::Basename;
 use Autom4te::ChannelDefs;
+use Autom4te::Channels qw(msg);
 use Autom4te::FileUtils;
 require Exporter;
@@ -218,22 +219,26 @@ sub lock
   my ($fh, $mode) = @_;
   # Cannot use @_ here.
-  # 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}
-         || (exists $ENV{'MAKEFLAGS'}
-             && " -$ENV{'MAKEFLAGS'}" =~ / (-[BdeikrRsSw]*j|---?jobs)/)))
+  # Unless explicitly configured otherwise, Perl implements its `flock' with 
+  # first of flock(2), fcntl(2), or lockf(3) that works.  These can fail on
+  # NFS-backed files, with ENOLCK (GNU/Linux) or EOPNOTSUPP (FreeBSD); we
+  # usually ignore these errors.  If $ENV{MAKEFLAGS} suggests that a parallel
+  # invocation of GNU `make' has invoked the tool we serve, report all locking
+  # failures and abort.
+  #
+  # On Unicos, flock(2) and fcntl(2) over NFS hang indefinitely when `lockd' is
+  # not running.  NetBSD NFS clients silently grant all locks.  We do not
+  # attempt to defend against these dangers.
+  if (!flock ($fh, $mode))
+      my $make_j = (exists $ENV{'MAKEFLAGS'}
+                   && " -$ENV{'MAKEFLAGS'}" =~ / (-[BdeikrRsSw]*j|---?jobs)/);
+      my $note = "\nforgo `make -j' or use a file system that supports locks";
       my $file = $fh->name;
-      fatal ("cannot lock $file with mode $mode "
-            . "(perhaps you are running make -j on a lame NFS client?): $!");
+      msg ($make_j ? 'fatal' : 'unsupported',
+          "cannot lock $file with mode $mode: $!" . ($make_j ? $note : ""))
+       if $make_j or not $!{ENOLCK} || $!{EOPNOTSUPP};

reply via email to

[Prev in Thread] Current Thread [Next in Thread]