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 <ian.jackson@eu.citrix.com>
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) {