From: Ian Jackson Date: Tue, 11 Feb 2020 18:32:38 +0000 (+0000) Subject: git-cache-proxy: Abandon fetch attempt if client disconnects X-Git-Tag: archive/debian/6.1.2~8 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?a=commitdiff_plain;h=c90b7cd9b44d02cf8c94ca92bb98266915896841;hp=d3b21a5bf9241594626cf766bdab00fd107edafc;p=chiark-utils.git git-cache-proxy: Abandon fetch attempt if client disconnects The git client sends the command and then waits for our response. We can tell if it has disconnected, because our stdin (the socket) will be readable. This is a good idea because otherwise if we have clients with their own (formal or informal) timeouts, we can build up a backlog of queued useless fetch attempts. Signed-off-by: Ian Jackson --- diff --git a/scripts/git-cache-proxy b/scripts/git-cache-proxy index 518ca9a..636ebfe 100755 --- a/scripts/git-cache-proxy +++ b/scripts/git-cache-proxy @@ -321,6 +321,19 @@ sub clonefetch () { if ($fetch) { + my $rbits = ''; + vec($rbits,0,1) = 1; + my $ebits = $rbits; + my $r=select $rbits,undef,$ebits,0; + $r>=0 or fail "select recheck STDOUT failed: $!"; + if ($r) { + servinfo 'client disconnected (stdin unexpectedly'. + (vec($rbits,0,1) ? ' readable' : ''). + (vec($ebits,0,1) ? ' exception' : ''). + ')'; + exit 0; + } + our @cmd; if (!$exists) {