Package: apt-cacher
Version: 1.5.3
I'm getting these in my daily email:
/etc/cron.daily/apt-cacher:
flock() on closed filehandle $lck at
/usr/share/apt-cacher/apt-cacher-cleanup.pl line 121.
flock() on closed filehandle $lck at
/usr/share/apt-cacher/apt-cacher-cleanup.pl line 123.
This is because the lock file doesn't exist at 120 (which isn't caught).
I wonder why the set/release_global_lock functions from
apt-cacher-lib.pl are not used? It looks like they used to be:
#define_global_lockfile("$config{cache_dir}/exlock");
But now it uses this instead:
my $globlockfile="$config{cache_dir}/private/exlock";
Though I'm not sure why the different path wasn't supplied if that's
what was required (although if it's really a global lock,
shouldn't it
match other definitions (/usr/sbin/apt-cache uses
$config{private_dir}/exlock).
I've made this change and attached the patch. It seems to work for me
(no errors), however I should point out that this install isn't live.
Adrian
--
Email: [EMAIL PROTECTED] -*- GPG key available on public key servers
Debian GNU/Linux - the maintainable distribution -*- www.debian.org
Avoid working with children, animals and Microsoft "operating" systems--- apt-cacher-cleanup.pl.orig 2007-06-09 09:18:43.000000000 +0100
+++ apt-cacher-cleanup.pl 2007-06-09 09:26:05.000000000 +0100
@@ -57,6 +57,9 @@
print @_ if $verbose;
}
+sub debug_message {
+}
+
#use strict;
#############################################################################
### configuration ###########################################################
@@ -74,6 +77,7 @@
die "Could not read config file: $@" if $@;
my $globlockfile="$config{cache_dir}/private/exlock";
+define_global_lockfile($globlockfile);
# check whether we're actually meant to clean the cache
if ( $config{clean_cache} ne 1 ) {
@@ -117,11 +121,9 @@
# file state decissions, lock that area
-open(my $lck, $globlockfile) || die "Unable to open $globlockfile";
-flock($lck, LOCK_EX);
+set_global_lock();
my @ifiles=(<*es.gz>, <*es.bz2>, <*es>, <*_Index>);
-flock($lck, LOCK_UN);
-close($lck);
+release_global_lock();
for (@ifiles) {
@@ -155,15 +157,13 @@
# get both locks and create a temp. copy
my $tmpfile= "$tempdir/$file";
- open(my $glck, $globlockfile);
- flock($glck, LOCK_EX);
+ set_global_lock();
open(my $lck, $file);
flock($lck, LOCK_EX);
link($file, $tmpfile);
flock($lck, LOCK_UN);
close($lck);
- flock($glck, LOCK_UN);
- close($glck);
+ release_global_lock();
if(-e $tmpfile && ! -s $tmpfile && $tmpfile=~/bz2$/) {
# moo, junk, empty file, most likely leftovers from previous versions