1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-05-29 16:46:10 +02:00

Merge branch 'jk/fetch-pack-v2-half-close-early' into next

"git fetch" over protocol v2 left its side of the socket open after
it finished speaking, which unnecessarily wasted the resource on
the other side.

* jk/fetch-pack-v2-half-close-early:
  fetch-pack: signal v2 server that we are done making requests
This commit is contained in:
Junio C Hamano 2021-05-28 13:13:25 +09:00
commit 56e97ec2df
2 changed files with 13 additions and 2 deletions

View File

@ -1645,6 +1645,15 @@ static struct ref *do_fetch_pack_v2(struct fetch_pack_args *args,
if (process_section_header(&reader, "packfile-uris", 1))
receive_packfile_uris(&reader, &packfile_uris);
process_section_header(&reader, "packfile", 0);
/*
* this is the final request we'll make of the server;
* do a half-duplex shutdown to indicate that they can
* hang up as soon as the pack is sent.
*/
close(fd[1]);
fd[1] = -1;
if (get_pack(args, fd, pack_lockfiles,
packfile_uris.nr ? &index_pack_args : NULL,
sought, nr_sought, &fsck_options.gitmodules_found))

View File

@ -427,7 +427,8 @@ static int fetch_refs_via_pack(struct transport *transport,
cleanup:
close(data->fd[0]);
close(data->fd[1]);
if (data->fd[1] >= 0)
close(data->fd[1]);
if (finish_connect(data->conn))
ret = -1;
data->conn = NULL;
@ -869,7 +870,8 @@ static int disconnect_git(struct transport *transport)
if (data->got_remote_heads && !transport->stateless_rpc)
packet_flush(data->fd[1]);
close(data->fd[0]);
close(data->fd[1]);
if (data->fd[1] >= 0)
close(data->fd[1]);
finish_connect(data->conn);
}