From: Ian Jackson Date: Sat, 9 Nov 2013 22:49:26 +0000 (+0000) Subject: git-cache-proxy: introduce servinfo X-Git-Tag: debian/4.2.1__iwj2~8 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?p=chiark-utils.git;a=commitdiff_plain;h=d89a6d9e1a8779b387fb915a0febc0aaaebd4a1e git-cache-proxy: introduce servinfo --- diff --git a/scripts/git-cache-proxy b/scripts/git-cache-proxy index f797e74..7cbbdc1 100755 --- a/scripts/git-cache-proxy +++ b/scripts/git-cache-proxy @@ -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->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: $!"; }