public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
To: "H.J. Lu" <hjl.tools@gmail.com>
Cc: binutils@sourceware.org
Subject: Re: PATCH: PR binutils/12283: bfd/doc doesn't support parallel build
Date: Thu, 02 Dec 2010 18:32:00 -0000	[thread overview]
Message-ID: <20101202183231.GD16143@gmx.de> (raw)
In-Reply-To: <20101202182235.GC16143@gmx.de>

* Ralf Wildenhues wrote on Thu, Dec 02, 2010 at 07:22:35PM CET:
> * Ralf Wildenhues wrote on Thu, Dec 02, 2010 at 07:20:50PM CET:
> > * H.J. Lu wrote on Thu, Dec 02, 2010 at 07:16:07PM CET:
> > > Failure is very random. There is a race condition. "make -j8" on a 16core
> > > machine can start making $(MKDOC) at the same time. How can move-if-change
> > > be 100% atomic?
> > 
> > Well, 'mv -f' within a mount point is atomic, that's how.
> 
> Ahh, move-if-change is broken: it doesn't ignore mv -f failure when the
> target is equal.  Let's fix move-if-change.

Does this alternative (untested) patch fix the race?

Thanks,
Ralf

ChangeLog:
2010-12-02  Ralf Wildenhues  <Ralf.Wildenhues@gmx.de>

	PR binutils/12283
	* move-if-change: Ignore failure of 'mv -f' if the destination
	is equal to the source afterwards.

diff --git a/move-if-change b/move-if-change
index ff74a55..1d2dd09 100755
--- a/move-if-change
+++ b/move-if-change
@@ -4,6 +4,8 @@
 
 usage="$0: usage: $0 SOURCE DEST"
 
+cmpprog=${CMPPROG-cmp}
+
 case $# in
 2) ;;
 *) echo "$usage" >&2; exit 1;;
@@ -18,5 +20,8 @@ done
 if test -r "$2" && cmp -s "$1" "$2"; then
   rm -f "$1"
 else
-  mv -f "$1" "$2"
+  if mv -f "$1" "$2"; then :; else
+    # Ignore failure due to a concurrent move-if-change.
+    $cmpprog "$1" "$2" >/dev/null 2>&1
+  fi
 fi

  reply	other threads:[~2010-12-02 18:32 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-12-02 17:00 H.J. Lu
2010-12-02 18:08 ` Ralf Wildenhues
2010-12-02 18:16   ` H.J. Lu
2010-12-02 18:20     ` Ralf Wildenhues
2010-12-02 18:22       ` Ralf Wildenhues
2010-12-02 18:32         ` Ralf Wildenhues [this message]
2010-12-02 18:40           ` H.J. Lu
2010-12-02 19:01             ` Ralf Wildenhues
2010-12-19 14:37           ` Ralf Wildenhues
2010-12-19 18:23             ` H.J. Lu
2011-01-27 23:57               ` Steve Ellcey
2011-01-28 20:15                 ` PATCH: import move-if-change from gnulib (was: PATCH: PR binutils/12283: bfd/doc doesn't support parallel build) Ralf Wildenhues
2011-01-28 21:12                   ` Steve Ellcey
2011-02-12 15:48                   ` Ralf Wildenhues
2011-01-28 23:32               ` PATCH: PR binutils/12283: bfd/doc doesn't support parallel build Steve Ellcey
2011-01-29  9:42                 ` Ralf Wildenhues
2011-01-31 18:33                   ` Steve Ellcey
2011-02-04  6:34                     ` Ralf Wildenhues
2011-02-04 17:51                       ` Andreas Schwab
2011-02-16  0:07                         ` Steve Ellcey
2011-02-16  5:09                           ` Ralf Wildenhues
2011-02-16 18:36                             ` Andreas Schwab
2011-02-05  0:25                       ` Steve Ellcey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20101202183231.GD16143@gmx.de \
    --to=ralf.wildenhues@gmx.de \
    --cc=binutils@sourceware.org \
    --cc=hjl.tools@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).