chiark / gitweb /
git-cache-proxy: Recheck gc timestamp after taking lock
authorIan Jackson <ian.jackson@eu.citrix.com>
Tue, 11 Feb 2020 18:56:04 +0000 (18:56 +0000)
committerIan Jackson <ian.jackson@eu.citrix.com>
Tue, 11 Feb 2020 19:11:35 +0000 (19:11 +0000)
Otherwise we can repeatedly gc the same thing.

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
scripts/git-cache-proxy

index 48c397c4fb0d4b81dcef369fc678772e98b1edd2..35ce5ff5754e97737a6c22efa773153d68a28827 100755 (executable)
@@ -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): $!";