From c64b6c5b0493a6d3cbf186ea0126e6b3242dd259 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Tue, 11 Feb 2020 18:56:04 +0000 Subject: [PATCH] git-cache-proxy: Recheck gc timestamp after taking lock Otherwise we can repeatedly gc the same thing. Signed-off-by: Ian Jackson --- scripts/git-cache-proxy | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/scripts/git-cache-proxy b/scripts/git-cache-proxy index 48c397c..35ce5ff 100755 --- a/scripts/git-cache-proxy +++ b/scripts/git-cache-proxy @@ -446,6 +446,13 @@ sub housekeeping () { $mode_what = 'garbage collecting'; $mode_locknb = 0; $mode_action = sub { + my ($needsgc, $gcmsg) = $gccheck->(); + if (!$needsgc) { + logm 'info', + "housekeeping: subdirs $subdir: someone else has gc'd"; + return; + } + logm 'debug', "housekeeping: subdirs $subdir: $gcmsg (2)"; my $gclog = "$subdir/gc.log"; unlink $gclog or $!==ENOENT or hkfail "remove $gclog: $!"; my $child = fork // hkfail "fork (for $subdir): $!"; -- 2.30.2