Hi again,
Well, sorry if it's all nonsense now: Last year I sent the
following mail, and got a reply confirming this bug and that it
may be changed to use pid instead of a serial in log filename.
Recently I was doing a project and had the same problem, I found
an atomic solution for that in man page for open(2). My case was
on an NFS filesystem and the note in the man page is for NFS too,
but I think it works for all systems and should solve the problem
in this bug too. Here it is:
O_EXCL When used with O_CREAT, if the file already exists
it is an error and the open will fail. In this con-
text, a symbolic link exists, regardless of where
its points to. O_EXCL is broken on NFS file sys-
tems, programs which rely on it for performing
locking tasks will contain a race condition. The
solution for performing atomic file locking using a
lockfile is to create a unique file on the same fs
(e.g., incorporating hostname and pid), use link(2)
to make a link to the lockfile. If link() returns
0, the lock is successful. Otherwise, use stat(2)
on the unique file to check if its link count has
increased to 2, in which case the lock is also suc-
cessful.
That won't work on Windows I suspect, but anyway, here we go.
Cheers,
behdad
GNU FriBidi and GNU Miscfiles maintainer
On Sun, 18 Jan 2004, Behdad Esfahbod wrote:
> Hi,
>
> I'm using wget from Fedora development snapshot, which introduces
> itself as GNU Wget 1.9+cvs-stable. I think there is a race
> condition in wget when allocating a log file.
>
> Here is a log to show that. What happens is that my system is
> under a bit of load, so the first (almost) twenty wgets all
> choose 'wget-log' as their log file:
>
>
> [EMAIL PROTECTED] x]$ while read x ; do wget -b -t0
> http://download.fedora.redhat.com/pub/fedora/linux/core/development/i386/Fedora/RPMS/$x.i386.rpm;
> done < ../packages
> Continuing in background, pid 24660.
> Output will be written to `wget-log'.
> Continuing in background, pid 24662.
> Output will be written to `wget-log'.
> Continuing in background, pid 24664.
> Output will be written to `wget-log'.
> Continuing in background, pid 24666.
> Output will be written to `wget-log'.
> Continuing in background, pid 24669.
> Output will be written to `wget-log'.
> Continuing in background, pid 24671.
> Output will be written to `wget-log'.
> Continuing in background, pid 24673.
> Output will be written to `wget-log'.
> Continuing in background, pid 24675.
> Output will be written to `wget-log'.
> Continuing in background, pid 24677.
> Output will be written to `wget-log'.
> Continuing in background, pid 24679.
> Output will be written to `wget-log'.
> Continuing in background, pid 24681.
> Output will be written to `wget-log'.
> Continuing in background, pid 24683.
> Output will be written to `wget-log'.
> Continuing in background, pid 24686.
> Output will be written to `wget-log'.
> Continuing in background, pid 24688.
> Output will be written to `wget-log'.
> Continuing in background, pid 24690.
> Output will be written to `wget-log'.
> Continuing in background, pid 24692.
> Output will be written to `wget-log'.
> Continuing in background, pid 24694.
> Output will be written to `wget-log'.
> Continuing in background, pid 24696.
> Output will be written to `wget-log'.
> Continuing in background, pid 24698.
> Output will be written to `wget-log'.
> Continuing in background, pid 24700.
> Output will be written to `wget-log'.
> Continuing in background, pid 24703.
> Output will be written to `wget-log'.
> Continuing in background, pid 24705.
> Output will be written to `wget-log'.
> Continuing in background, pid 24707.
> Output will be written to `wget-log'.
> Continuing in background, pid 24709.
> Output will be written to `wget-log'.
> Continuing in background, pid 24711.
> Output will be written to `wget-log'.
> Continuing in background, pid 24713.
> Output will be written to `wget-log'.
> Continuing in background, pid 24715.
> Output will be written to `wget-log'.
> Continuing in background, pid 24717.
> Output will be written to `wget-log'.
> Continuing in background, pid 24719.
> Output will be written to `wget-log'.
> Continuing in background, pid 24722.
> Output will be written to `wget-log'.
> Continuing in background, pid 24724.
> Output will be written to `wget-log'.
> Continuing in background, pid 24726.
> Output will be written to `wget-log.1'.
> Continuing in background, pid 24728.
> Output will be written to `wget-log.2'.
> Continuing in background, pid 24730.
> Output will be written to `wget-log.3'.
> Continuing in background, pid 24732.
> Output will be written to `wget-log.4'.
> Continuing in background, pid 24734.
> Output will be written to `wget-log.5'.
> Continuing in background, pid 24739.
> Output will be written to `wget-log.6'.
> Continuing in background, pid 24741.
> Output will be written to `wget-log.7'.
> Continuing in background, pid 24744.
> Output will be written to `wget-log.8'.
> Continuing in background, pid 24747.
> Output will be written to `wget-log.9'.
> Continuing in background, pid 24749.
> Output will be written to `wget-log.10'.
> Continuing in background, pid 24751.
> Output will be written to `wget-log.11'.
> Continuing in background, pid 24753.
> Output will be written to `wget-log.12'.
>
>
--behdad
http://behdad.org/