aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2021-06-14 13:33:26 +0900
committerJunio C Hamano <gitster@pobox.com>2021-06-14 13:33:26 +0900
commit4dd75a195b06680cf43dd7c116b53a561ae8d11c (patch)
tree726ee0fa30c14a172507e4453999a024e0173205
parentMerge branch 'ds/write-index-with-hashfile-api' (diff)
parentfetch-pack: signal v2 server that we are done making requests (diff)
downloadgit-4dd75a195b06680cf43dd7c116b53a561ae8d11c.tar.gz
git-4dd75a195b06680cf43dd7c116b53a561ae8d11c.zip
Merge branch 'jk/fetch-pack-v2-half-close-early'
"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
-rw-r--r--fetch-pack.c9
-rw-r--r--transport.c6
2 files changed, 13 insertions, 2 deletions
diff --git a/fetch-pack.c b/fetch-pack.c
index c135635e34..b0c7be717c 100644
--- a/fetch-pack.c
+++ b/fetch-pack.c
@@ -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))
diff --git a/transport.c b/transport.c
index 6cf3da19eb..50f5830eb6 100644
--- a/transport.c
+++ b/transport.c
@@ -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);
}