Skip to content

Commit

Permalink
smart-http: Don't deadlock on server failure
Browse files Browse the repository at this point in the history
If the remote HTTP server fails (e.g. returns 404 or 500) when we
posted the RPC to it, we won't have sent anything to the background
Git process that is supposed to handle the stream.  Because we
didn't send anything, its waiting for input from remote-curl, and
remote-curl cannot read its response payload because doing so would
lead to a deadlock.

Send the background task EOF on its input before we try to read
its response back, that way it will break out of its read loop
and terminate.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Shawn O. Pearce authored and Junio C Hamano committed Aug 6, 2010
1 parent 4133fd2 commit b4ee10f
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions remote-curl.c
Original file line number Diff line number Diff line change
Expand Up @@ -505,11 +505,12 @@ static int rpc_service(struct rpc_state *rpc, struct discovery *heads)
rpc->len = n;
err |= post_rpc(rpc);
}
strbuf_read(&rpc->result, client.out, 0);

close(client.in);
close(client.out);
client.in = -1;
strbuf_read(&rpc->result, client.out, 0);

close(client.out);
client.out = -1;

err |= finish_command(&client);
Expand Down

0 comments on commit b4ee10f

Please sign in to comment.