fetch-pack: Prepare for a side-band demultiplexer in a thread.
commit1f759eeede0597580be8ce26305550350e3c017a
authorJohannes Sixt <johannes.sixt@telecom.at>
Sat, 17 Nov 2007 22:09:28 +0000 (17 23:09 +0100)
committerJunio C Hamano <gitster@pobox.com>
Sun, 18 Nov 2007 04:27:29 +0000 (17 20:27 -0800)
tree4fd24e79e76c697ebf1bf670c2980d4526910ac0
parent5f9ffff308845e2439670ec3cb2c12f4865cf430
fetch-pack: Prepare for a side-band demultiplexer in a thread.

get_pack() receives a pair of file descriptors that communicate with
upload-pack at the remote end. In order to support the case where the
side-band demultiplexer runs in a thread, and, hence, in the same process
as the main routine, we must not close the readable file descriptor early.

The handling of the readable fd is changed in the case where upload-pack
supports side-band communication: The old code closed the fd after it was
inherited to the side-band demultiplexer process. Now we do not close it.
The caller (do_fetch_pack) will close it later anyway. The demultiplexer
is the only reader, it does not matter that the fd remains open in the
main process as well as in unpack-objects/index-pack, which inherits it.

The writable fd is not needed in get_pack(), hence, the old code closed
the fd. For symmetry with the readable fd, we now do not close it; the
caller (do_fetch_pack) will close it later anyway. Therefore, the new
behavior is that the channel now remains open during the entire
conversation, but this has no ill effects because upload-pack does not read
from it once it has begun to send the pack data. For the same reason it
does not matter that the writable fd is now inherited to the demultiplexer
and unpack-objects/index-pack processes.

Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin-fetch-pack.c