Hello Jay,
On Sat, Feb 12, 2005 at 08:01:17PM +0100, Jeroen van Wolffelaar wrote:
> /org/ftp.debian.org/ftp is full:
...
> Ultimately, debmirror fails, but without a clueful error message, after 2
> minutes. Issues like out of diskspace and permissions problems can be
> detected right away, it's a bit annoying for it take 2 minutes, and then
> still not have a correct error message.
The attached patch seems to work for me. Could you review and apply if
it is ok?
There are still races, e.g., if the process on another host is aborted
after creating the file but before writing to it. I haven't tested this
scenario.
Does upstream have a testsuite?
With kind regards,
Baurzhan.
diff -Naurp -X /home/ibr/tmp/root/prg/dontdiff.ibr
liblockfile-simple-perl-0.2.5.orig/Simple.pm
liblockfile-simple-perl-0.2.5/Simple.pm
--- liblockfile-simple-perl-0.2.5.orig/Simple.pm 2005-08-08
23:10:51.000000000 +0200
+++ liblockfile-simple-perl-0.2.5/Simple.pm 2005-08-08 23:09:37.000000000
+0200
@@ -398,7 +398,16 @@ sub _acs_lock { ## private
# Attempt to create lock
if (open(FILE, ">$lockfile")) {
local $\ = undef;
- print FILE "$stamp\n";
+ my $buf = "$stamp\n";
+ if (!syswrite(FILE, $buf, length($buf))) {
+ print STDERR "$0: writing to $lockfile: $!\n";
+ close(FILE);
+ if (!unlink($lockfile)) {
+ print STDERR "$0: removing $lockfile: $!";
+ }
+ umask($mask);
+ return 0; # Couldn't write to file
+ }
close FILE;
open(FILE, $lockfile); # Check lock
my $l;