From: Ian Jackson Date: Tue, 11 Feb 2020 18:56:04 +0000 (+0000) Subject: git-cache-proxy: Recheck gc timestamp after taking lock X-Git-Tag: archive/debian/6.1.2~4 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?a=commitdiff_plain;h=c64b6c5b0493a6d3cbf186ea0126e6b3242dd259;p=chiark-utils.git git-cache-proxy: Recheck gc timestamp after taking lock Otherwise we can repeatedly gc the same thing. Signed-off-by: Ian Jackson --- 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): $!";