[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Update cache files atomically.
From: |
Ralf Wildenhues |
Subject: |
Update cache files atomically. |
Date: |
Tue, 7 Oct 2008 22:29:54 +0200 |
User-agent: |
Mutt/1.5.18 (2008-05-17) |
When several configure scripts run in parallel (in different build
directories) and share the same config.cache file, there is a race
condition when saving the cache. I don't know of a package that does
this, and the AC_CONFIG_SUBDIRS code doesn't provide this functionality,
but FWIW here's code that would fix it, by letting the last saver win.
I've had this on my disk for a long time; the list archives may serve
just as well. I don't know whether there is any benefit in using it.
Cheers,
Ralf
Update cache files atomically.
* lib/autoconf/general.m4 (AC_CACHE_SAVE): Update $cache_file
atomically.
* NEWS: Update.
diff --git a/NEWS b/NEWS
index 0a2fbd4..ca04535 100644
--- a/NEWS
+++ b/NEWS
@@ -11,6 +11,8 @@ GNU Autoconf NEWS - User visible changes.
** The following m4sugar macros are new:
m4_default_quoted
+** config.cache files are updated atomically.
+
* Major changes in Autoconf 2.63 (2008-09-09) [stable]
Released by Eric Blake, based on git versions 2.62.*.
diff --git a/lib/autoconf/general.m4 b/lib/autoconf/general.m4
index 986b7af..a8437b6 100644
--- a/lib/autoconf/general.m4
+++ b/lib/autoconf/general.m4
@@ -1950,9 +1950,14 @@ _AC_CACHE_DUMP() |
:end'] >>confcache
if diff "$cache_file" confcache >/dev/null 2>&1; then :; else
if test -w "$cache_file"; then
- test "x$cache_file" != "x/dev/null" &&
+ if test "x$cache_file" != "x/dev/null"; then
AC_MSG_NOTICE([updating cache $cache_file])
- cat confcache >$cache_file
+ if test -f "$cache_file"; then
+ mv -f confcache "$cache_file"
+ else
+ cat confcache >"$cache_file"
+ fi
+ fi
else
AC_MSG_NOTICE([not updating unwritable cache $cache_file])
fi
- Update cache files atomically.,
Ralf Wildenhues <=