path: root/remote-curl.c
diff options
authorShawn O. Pearce <>2010-08-06 21:19:44 (GMT)
committerJunio C Hamano <>2010-08-06 22:30:16 (GMT)
commitb4ee10f60fb46e0305968023c1ab0f072535b630 (patch)
tree6960e8625cdd0b4d1e3e6b812d56d6244a016972 /remote-curl.c
parent4133fd25525022f99d2c7ba339618433bdd919fe (diff)
smart-http: Don't deadlock on server failure
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 <> Signed-off-by: Junio C Hamano <>
Diffstat (limited to 'remote-curl.c')
1 files changed, 3 insertions, 2 deletions
diff --git a/remote-curl.c b/remote-curl.c
index 3edbf57..5416891 100644
--- a/remote-curl.c
+++ b/remote-curl.c
@@ -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.out); = -1;
+ strbuf_read(&rpc->result, client.out, 0);
+ close(client.out);
client.out = -1;
err |= finish_command(&client);