chiark / gitweb /
git-cache-proxy: introduce servinfo
[chiark-utils.git] / scripts / git-cache-proxy
index f797e74920cc36822141ad2422ad683d6f8e4281..7cbbdc1aec496d4d1f5a11dd7373b20c2dff9bc2 100755 (executable)
@@ -172,6 +172,11 @@ sub xread {
     return $buffer;
 }
 
+sub servinfo ($) {
+    my ($msg) = @_;
+    logm 'info', "service `$specpath': $msg";
+}
+
 sub readcommand () {
     $SIG{ALRM} = sub { fail "timeout" };
     alarm 30;
@@ -218,11 +223,11 @@ sub readcommand () {
     $subdir =~ s|,|\\,|g;
     $subdir =~ s|/|,|g;
 
-    logm 'info', "$specpath locking";
-    
     $tmpd= "$subdir\\.tmp";
     $gitd= "$subdir\\.git";
     $lock = "$subdir\\.lock";
+
+    servinfo "locking";
 }
 
 sub clonefetch () {
@@ -241,10 +246,10 @@ sub clonefetch () {
        if (!$exists) {
            system qw(rm -rf --), $tmpd;
            @cmd = (qw(git clone -q --mirror), $url, $tmpd);
-           logm 'info', "$specpath cloning @cmd";
+           servinfo "cloning";
        } else {
            @cmd = (qw(git remote update --prune));
-           logm 'info', "$specpath fetching @cmd";
+           servinfo "fetching";
        }
        my $cmd = "@cmd[0..1]";
 
@@ -263,10 +268,9 @@ sub clonefetch () {
        my $timedout = 0;
        {
            local $SIG{ALRM} = sub {
-               logm 'info', "$specpath fetch/clone timeout";
+               servinfo "fetch/clone timeout";
                $timedout=1; kill 9, -$child;
            };
-logm 'info', "timeout=$fetchtimeout";
            alarm($fetchtimeout);
            $!=0; { local $/=undef; $fetcherr = <FETCHERR>; }
            !FETCHERR->error or fail "read pipe from fetch/clone: $!";
@@ -289,7 +293,7 @@ logm 'info', "timeout=$fetchtimeout";
            if ($fetch >= 2) {
                gitfail $fetchfail;
            } else {
-               logm 'info', "$specpath fetch/clone failed: $fetchfail";
+               servinfo "fetch/clone failed: $fetchfail";
            }
        }
 
@@ -305,7 +309,7 @@ logm 'info', "timeout=$fetchtimeout";
        gitfail "no cached data, and not cloned: $fetchfail";
     }
 
-    logm 'info', "$specpath sharing";
+    servinfo "sharing";
     flock LOCK, LOCK_UN or fail "unlock $lock: $!";
     flock LOCK, LOCK_SH or fail "lock shared $lock: $!";
     # actually, just relocking as shared would have the same semantics
@@ -322,7 +326,7 @@ logm 'info', "timeout=$fetchtimeout";
 }
 
 sub runcommand () {
-    logm 'info', "$specpath servicing";
+    servinfo "servicing";
     exec qw(git-upload-pack --strict --timeout=1000 .)
        or fail "exec git-upload-pack: $!";
 }