mirror of
git://git.sv.gnu.org/autoconf
synced 2025-01-18 10:45:15 +08:00
Lock autom4te's cache.
* lib/Autom4te/XFile.pm ($me, &name, &lock, &truncate, &seek): New. * bin/autom4te.in (&Request::save, &Request::load): Use an IO::File argument instead of a file name, so that the request file remains open during the whole autom4te run. ($icache_file): New. (&freeze): Lock the $icache_file.
This commit is contained in:
parent
f2da1c1ca5
commit
db4f0f52c0
11
ChangeLog
11
ChangeLog
@ -1,6 +1,13 @@
|
||||
2003-05-05 Derek Price <derek@ximbiot.com>
|
||||
2003-05-06 Akim Demaille <akim@epita.fr>
|
||||
|
||||
* lib/emacs/.cvsignore: Add generated elc-stamp file.
|
||||
Lock autom4te's cache.
|
||||
|
||||
* lib/Autom4te/XFile.pm ($me, &name, &lock, &truncate, &seek): New.
|
||||
* bin/autom4te.in (&Request::save, &Request::load): Use an IO::File
|
||||
argument instead of a file name, so that the request file remains
|
||||
open during the whole autom4te run.
|
||||
($icache_file): New.
|
||||
(&freeze): Lock the $icache_file.
|
||||
|
||||
2003-04-29 Derek Price <derek@ximbiot.com>
|
||||
|
||||
|
5
NEWS
5
NEWS
@ -14,6 +14,11 @@
|
||||
configure: WARNING: pi.h: proceeding with the preprocessor's result
|
||||
messages.
|
||||
|
||||
* Concurrent executions of autom4te
|
||||
autom4te now locks its internal files, which enables concurrent
|
||||
executions of autom4te, likely to happen if automake, autoconf,
|
||||
autoheader etc. are run simultaneously.
|
||||
|
||||
* Major changes in Autoconf 2.57
|
||||
|
||||
Released 2002-12-03 by Paul Eggert.
|
||||
|
@ -6,7 +6,7 @@ eval 'case $# in 0) exec @PERL@ -S "$0";; *) exec @PERL@ -S "$0" "$@";; esac'
|
||||
if 0;
|
||||
|
||||
# autom4te - Wrapper around M4 libraries.
|
||||
# Copyright (C) 2001, 2002 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2001, 2002, 2003 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
|
||||
@ -189,17 +189,19 @@ sub includes_p
|
||||
}
|
||||
|
||||
|
||||
# SAVE ($FILENAME)
|
||||
# ----------------
|
||||
# SAVE ($FILE)
|
||||
# ------------
|
||||
# Save the cache in the $FILE Autom4te::XFile object.
|
||||
sub save
|
||||
{
|
||||
my ($self, $filename) = @_;
|
||||
my ($self, $file) = @_;
|
||||
|
||||
croak "$me: cannot save a single request\n"
|
||||
if ref ($self);
|
||||
|
||||
my $requests = new Autom4te::XFile ("> $filename");
|
||||
print $requests
|
||||
$file->seek (0, 0);
|
||||
$file->truncate (0);
|
||||
print $file
|
||||
"# This file was created by $me.\n",
|
||||
"# It contains the lists of macros which have been traced.\n",
|
||||
"# It can be safely removed.\n",
|
||||
@ -210,18 +212,20 @@ sub save
|
||||
|
||||
# LOAD ($FILE)
|
||||
# ------------
|
||||
# "eval" the content of the $FILE Autom4te::XFile object.
|
||||
sub load
|
||||
{
|
||||
my ($self, $file) = @_;
|
||||
my $fname = $file->name;
|
||||
|
||||
croak "$me: cannot load a single request\n"
|
||||
if ref ($self);
|
||||
|
||||
(my $return) = do "$file";
|
||||
my $contents = join "", $file->getlines;
|
||||
|
||||
croak "$me: cannot parse $file: $@\n" if $@;
|
||||
croak "$me: cannot do $file: $!\n" unless defined $return;
|
||||
croak "$me: cannot run $file\n" unless $return;
|
||||
eval $contents;
|
||||
|
||||
croak "$me: cannot eval $fname: $@\n" if $@;
|
||||
}
|
||||
|
||||
|
||||
@ -251,11 +255,12 @@ my $mode = "0666";
|
||||
my $melt = 0;
|
||||
|
||||
# Names of the cache directory, cache directory index, trace cache
|
||||
# prefix, and output cache prefix.
|
||||
# prefix, and output cache prefix. And the IO objet for the index.
|
||||
my $cache;
|
||||
my $icache;
|
||||
my $tcache;
|
||||
my $ocache;
|
||||
my $icache_file;
|
||||
|
||||
# The macros to trace mapped to their format, as specified by the
|
||||
# user.
|
||||
@ -415,7 +420,7 @@ $version = <<"EOF";
|
||||
autom4te (@PACKAGE_NAME@) @VERSION@
|
||||
Written by Akim Demaille.
|
||||
|
||||
Copyright 2002 Free Software Foundation, Inc.
|
||||
Copyright (C) 2003 Free Software Foundation, Inc.
|
||||
This is free software; see the source for copying conditions. There is NO
|
||||
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
EOF
|
||||
@ -1170,10 +1175,16 @@ if (! -d "$cache")
|
||||
or error "cannot create $cache: $!";
|
||||
}
|
||||
|
||||
# Open the index for update, and lock it. autom4te handles several
|
||||
# files, but the index is the first and last file to be update, so
|
||||
# locking it is sufficient.
|
||||
$icache_file = new Autom4te::XFile $icache, O_RDWR|O_CREAT;
|
||||
$icache_file->lock (LOCK_EX);
|
||||
|
||||
# Read the cache index if available and older than autom4te itself.
|
||||
# If autom4te is younger, then some structures such as Request, might
|
||||
# have changed, which would corrupt its processing.
|
||||
Request->load ($icache)
|
||||
Request->load ($icache_file)
|
||||
if -f $icache && mtime ($icache) > mtime ($0);
|
||||
|
||||
# Add the new trace requests.
|
||||
@ -1216,7 +1227,7 @@ else
|
||||
$req->valid (1)
|
||||
if $exit_status == 0;
|
||||
|
||||
Request->save ($icache);
|
||||
Request->save ($icache_file);
|
||||
|
||||
exit $exit_status;
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
# Copyright 2001 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2001, 2003 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
|
||||
@ -63,9 +63,11 @@ Autom4te::XFile - supply object methods for filehandles with error handling
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
C<Autom4te::XFile> inherits from C<IO::File>. It provides dying
|
||||
version of the methods C<open>, C<new>, and C<close>. It also overrides
|
||||
the C<getline> and C<getlines> methods to translate C<\r\n> to C<\n>.
|
||||
C<Autom4te::XFile> inherits from C<IO::File>. It provides the method
|
||||
C<name> returning the file name. It provides dying version of the
|
||||
methods C<close>, C<lock> (corresponding to C<flock>), C<new>,
|
||||
C<open>, C<seek>, and C<trunctate>. It also overrides the C<getline>
|
||||
and C<getlines> methods to translate C<\r\n> to C<\n>.
|
||||
|
||||
=head1 SEE ALSO
|
||||
|
||||
@ -85,6 +87,7 @@ require 5.000;
|
||||
use strict;
|
||||
use vars qw($VERSION @EXPORT @EXPORT_OK $AUTOLOAD @ISA);
|
||||
use Carp;
|
||||
use IO::File;
|
||||
use File::Basename;
|
||||
|
||||
require Exporter;
|
||||
@ -92,18 +95,20 @@ require DynaLoader;
|
||||
|
||||
@ISA = qw(IO::File Exporter DynaLoader);
|
||||
|
||||
$VERSION = "1.1";
|
||||
$VERSION = "1.2";
|
||||
|
||||
@EXPORT = @IO::File::EXPORT;
|
||||
|
||||
eval {
|
||||
# Make all Fcntl O_XXX constants available for importing
|
||||
require Fcntl;
|
||||
my @O = grep /^O_/, @Fcntl::EXPORT;
|
||||
Fcntl->import(@O); # first we import what we want to export
|
||||
push(@EXPORT, @O);
|
||||
# Make all Fcntl O_XXX and LOCK_XXX constants available for importing
|
||||
require Fcntl;
|
||||
my @O = grep /^(LOCK|O)_/, @Fcntl::EXPORT, @Fcntl::EXPORT_OK;
|
||||
Fcntl->import (@O); # first we import what we want to export
|
||||
push (@EXPORT, @O);
|
||||
};
|
||||
|
||||
# Used in croak error messages.
|
||||
my $me = basename ($0);
|
||||
|
||||
################################################
|
||||
## Constructor
|
||||
@ -138,7 +143,6 @@ sub open
|
||||
|
||||
if (!$fh->SUPER::open (@_))
|
||||
{
|
||||
my $me = basename ($0);
|
||||
croak "$me: cannot open $file: $!\n";
|
||||
}
|
||||
|
||||
@ -158,8 +162,7 @@ sub close
|
||||
my ($fh) = shift;
|
||||
if (!$fh->SUPER::close (@_))
|
||||
{
|
||||
my $me = basename ($0);
|
||||
my $file = ${*$fh}{'autom4te_xfile_file'};
|
||||
my $file = $fh->name;
|
||||
croak "$me: cannot close $file: $!\n";
|
||||
}
|
||||
}
|
||||
@ -172,11 +175,11 @@ sub close
|
||||
# so we do that here.
|
||||
sub getline
|
||||
{
|
||||
local $_ = $_[0]->SUPER::getline;
|
||||
# Perform a _global_ replacement: $_ may can contains many lines
|
||||
# in slurp mode ($/ = undef).
|
||||
s/\015\012/\n/gs if defined $_;
|
||||
return $_;
|
||||
local $_ = $_[0]->SUPER::getline;
|
||||
# Perform a _global_ replacement: $_ may can contains many lines
|
||||
# in slurp mode ($/ = undef).
|
||||
s/\015\012/\n/gs if defined $_;
|
||||
return $_;
|
||||
}
|
||||
|
||||
################################################
|
||||
@ -185,10 +188,64 @@ sub getline
|
||||
|
||||
sub getlines
|
||||
{
|
||||
my @res = ();
|
||||
my $line;
|
||||
push @res, $line while $line = $_[0]->getline;
|
||||
return @res;
|
||||
my @res = ();
|
||||
my $line;
|
||||
push @res, $line while $line = $_[0]->getline;
|
||||
return @res;
|
||||
}
|
||||
|
||||
################################################
|
||||
## Name
|
||||
##
|
||||
|
||||
sub name
|
||||
{
|
||||
my ($fh) = shift;
|
||||
return ${*$fh}{'autom4te_xfile_file'};
|
||||
}
|
||||
|
||||
################################################
|
||||
## Lock
|
||||
##
|
||||
|
||||
sub lock
|
||||
{
|
||||
use Fcntl qw(:DEFAULT :flock);
|
||||
my ($fh) = shift;
|
||||
if (!flock ($fh, @_))
|
||||
{
|
||||
my $file = $fh->name;
|
||||
croak "$me: cannot lock $file with @_: $!\n";
|
||||
}
|
||||
}
|
||||
|
||||
################################################
|
||||
## Seek
|
||||
##
|
||||
|
||||
sub seek
|
||||
{
|
||||
my ($fh) = shift;
|
||||
# Cannot use @_ here.
|
||||
if (!seek ($fh, $_[0], $_[1]))
|
||||
{
|
||||
my $file = $fh->name;
|
||||
croak "$me: cannot rewind $file with @_: $!\n";
|
||||
}
|
||||
}
|
||||
|
||||
################################################
|
||||
## Truncate
|
||||
##
|
||||
|
||||
sub truncate
|
||||
{
|
||||
my ($fh) = shift;
|
||||
if (!truncate ($fh, @_))
|
||||
{
|
||||
my $file = $fh->name;
|
||||
croak "$me: cannot truncate $file with @_: $!\n";
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
||||
|
@ -111,12 +111,13 @@ prepare to trace MACRO in a future run
|
||||
produce an M4 frozen state file for FILES
|
||||
.SH AUTHOR
|
||||
Written by Akim Demaille.
|
||||
.PP
|
||||
Copyright 2002 Free Software Foundation, Inc.
|
||||
This is free software; see the source for copying conditions. There is NO
|
||||
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
.SH "REPORTING BUGS"
|
||||
Report bugs to <bug-autoconf@gnu.org>.
|
||||
.SH COPYRIGHT
|
||||
Copyright \(co 2003 Free Software Foundation, Inc.
|
||||
.br
|
||||
This is free software; see the source for copying conditions. There is NO
|
||||
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
.SH "SEE ALSO"
|
||||
.BR autoconf (1),
|
||||
.BR automake (1),
|
||||
|
Loading…
Reference in New Issue
Block a user