Skip to content

Commit b4ee10f

Browse files
spearcegitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 4133fd2 commit b4ee10f

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

remote-curl.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -505,11 +505,12 @@ static int rpc_service(struct rpc_state *rpc, struct discovery *heads)
505505
rpc->len = n;
506506
err |= post_rpc(rpc);
507507
}
508-
strbuf_read(&rpc->result, client.out, 0);
509508

510509
close(client.in);
511-
close(client.out);
512510
client.in = -1;
511+
strbuf_read(&rpc->result, client.out, 0);
512+
513+
close(client.out);
513514
client.out = -1;
514515

515516
err |= finish_command(&client);

0 commit comments

Comments
 (0)