Skip to content

Commit 3ef67cf

Browse files
j6tgitster
authored andcommitted
fetch-pack: close output channel after sideband demultiplexer terminates
fetch-pack runs the sideband demultiplexer using start_async(). This facility requires that the asynchronously executed function closes the output file descriptor (see Documentation/technical/api-run-command.txt). But the sideband demultiplexer did not do that. This fixes it. In certain error situations this could lock up a fetch operation on Windows because the asynchronous function is run in a thread; by not closing the output fd the reading end never got EOF and waited for more data indefinitely. On Unix this is not a problem because the asynchronous function is run in a separate process, which exits after the function ends and so implicitly closes the output. Since the pack that is sent over the wire encodes the number of objects in the stream, during normal operation the reading end knows when the stream ends and terminates by itself, and does not lock up. Signed-off-by: Johannes Sixt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 956d27a commit 3ef67cf

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

builtin-fetch-pack.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,9 @@ static int sideband_demux(int fd, void *data)
483483
{
484484
int *xd = data;
485485

486-
return recv_sideband("fetch-pack", xd[0], fd);
486+
int ret = recv_sideband("fetch-pack", xd[0], fd);
487+
close(fd);
488+
return ret;
487489
}
488490

489491
static int get_pack(int xd[2], char **pack_lockfile)

0 commit comments

Comments
 (0)