~ubuntu-branches/ubuntu/maverick/autoconf/maverick

« back to all changes in this revision

Viewing changes to lib/Autom4te/XFile.pm

  • Committer: Bazaar Package Importer
  • Author(s): Ben Pfaff
  • Date: 2007-01-17 19:57:13 UTC
  • mfrom: (3.1.7 feisty)
  • Revision ID: james.westby@ubuntu.com-20070117195713-n2q7e2pbpu4ezbx7
Tags: 2.61-4
debian/control: Require m4 version 1.4.8 or later.  Thanks to Jim
Paris <jim@jtan.com> for reporting this bug.  Closes: #407385.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2001, 2003 Free Software Foundation, Inc.
 
1
# Copyright (C) 2001, 2003, 2004, 2006 Free Software Foundation, Inc.
2
2
 
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
12
12
 
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
 
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
16
 
# 02111-1307, USA.
 
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 
16
# 02110-1301, USA.
17
17
 
18
18
# Written by Akim Demaille <akim@freefriends.org>.
19
19
 
91
91
use IO::File;
92
92
use File::Basename;
93
93
use Autom4te::ChannelDefs;
 
94
use Autom4te::Channels qw(msg);
94
95
use Autom4te::FileUtils;
95
96
 
96
97
require Exporter;
218
219
  my ($fh, $mode) = @_;
219
220
  # Cannot use @_ here.
220
221
 
221
 
  # On some systems (e.g. GNU/Linux with NFSv2), flock(2) does not work over
222
 
  # NFS, but Perl prefers that over fcntl(2) if it exists and if
223
 
  # perl was not built with -Ud_flock.  Normally, this problem is harmless,
224
 
  # so ignore the ENOLCK errors that are reported in that situation,
225
 
  # However, if the invoker is using "make -j", the problem is not harmless,
226
 
  # so report it in that case, by inspecting MAKEFLAGS and looking for
227
 
  # any arguments indicating that the invoker used -j.
228
 
  # Admittedly this is a bit of a hack.
229
 
  if (!flock ($fh, $mode)
230
 
      && (!$!{ENOLCK}
231
 
          || " -$ENV{'MAKEFLAGS'}" =~ / (-[BdeikrRsSw]*j|---?jobs)/))
 
222
  # Unless explicitly configured otherwise, Perl implements its `flock' with the
 
223
  # first of flock(2), fcntl(2), or lockf(3) that works.  These can fail on
 
224
  # NFS-backed files, with ENOLCK (GNU/Linux) or EOPNOTSUPP (FreeBSD); we
 
225
  # usually ignore these errors.  If $ENV{MAKEFLAGS} suggests that a parallel
 
226
  # invocation of GNU `make' has invoked the tool we serve, report all locking
 
227
  # failures and abort.
 
228
  #
 
229
  # On Unicos, flock(2) and fcntl(2) over NFS hang indefinitely when `lockd' is
 
230
  # not running.  NetBSD NFS clients silently grant all locks.  We do not
 
231
  # attempt to defend against these dangers.
 
232
  if (!flock ($fh, $mode))
232
233
    {
 
234
      my $make_j = (exists $ENV{'MAKEFLAGS'}
 
235
                    && " -$ENV{'MAKEFLAGS'}" =~ / (-[BdeikrRsSw]*j|---?jobs)/);
 
236
      my $note = "\nforgo `make -j' or use a file system that supports locks";
233
237
      my $file = $fh->name;
234
 
      fatal "cannot lock $file with mode $mode (perhaps you are running make -j on a lame NFS client?): $!";
 
238
 
 
239
      msg ($make_j ? 'fatal' : 'unsupported',
 
240
           "cannot lock $file with mode $mode: $!" . ($make_j ? $note : ""))
 
241
        if $make_j || !($!{ENOLCK} || $!{EOPNOTSUPP});
235
242
    }
236
243
}
237
244