From: Derrick Stolee <stolee@gmail.com>
To: Jeff King <peff@peff.net>,
"brian m. carlson" <sandals@crustytoothpaste.net>
Cc: git@vger.kernel.org, Jonathan Tan <jonathantanmy@google.com>
Subject: Re: [PATCH] transport: don't flush when disconnecting stateless-rpc helper
Date: Wed, 8 Jan 2020 08:43:21 -0500 [thread overview]
Message-ID: <bc8f8c12-75d0-c79c-2778-0e7afe6b796a@gmail.com> (raw)
In-Reply-To: <20200108071009.GA1675456@coredump.intra.peff.net>
On 1/8/2020 2:10 AM, Jeff King wrote:
> On Wed, Jan 08, 2020 at 03:34:51AM +0000, brian m. carlson wrote:
>
>> A colleague (Jon Simons) today pointed out an interesting behavior of
>> git ls-remote with protocol v2: it makes a second POST request and sends
>> only a flush packet. This can be demonstrated with the following:
>>
>> GIT_CURL_VERBOSE=1 git -c protocol.version=2 ls-remote origin
>>
>> The Content-Length header on the second request will be exactly 4 bytes.
Good find!
> But when we've initiated a v2 stateless-connect session over a transport
> helper, there's no point in sending this flush packet. Each operation
> we've performed is self-contained, and the other side is fine with us
> hanging up between operations.
Makes sense to me.
> But much worse, by sending the flush packet we may cause the helper to
> issue an entirely new request _just_ to send the flush packet. So we can
> incur an extra network request just to say "by the way, we have nothing
> more to send".
>
> Let's drop this extra flush packet. As the test shows, this reduces the
> number of POSTs required for a v2 ls-remote over http from 2 to 1.
> +test_expect_success 'ls-remote with v2 http sends only one POST' '
> + test_when_finished "rm -f log" &&
> +
> + git ls-remote "$HTTPD_DOCUMENT_ROOT_PATH/http_parent" >expect &&
> + GIT_TRACE_CURL="$(pwd)/log" git -c protocol.version=2 \
> + ls-remote "$HTTPD_URL/smart/http_parent" >actual &&
> + test_cmp expect actual &&
> +
> + grep "Send header: POST" log >posts &&
> + test_line_count = 1 posts
> +'
> +
Nice test!
> diff --git a/transport.c b/transport.c
> index 83379a037d..1fdc7dac1a 100644
> --- a/transport.c
> +++ b/transport.c
> @@ -737,7 +737,7 @@ static int disconnect_git(struct transport *transport)
> {
> struct git_transport_data *data = transport->data;
> if (data->conn) {
> - if (data->got_remote_heads)
> + if (data->got_remote_heads && !transport->stateless_rpc)
> packet_flush(data->fd[1]);
> close(data->fd[0]);
> close(data->fd[1]);
Looks good to me. Thanks!
-Stolee
prev parent reply other threads:[~2020-01-08 13:43 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-08 3:34 Extra request with protocol v2 and git ls-remote brian m. carlson
2020-01-08 7:10 ` [PATCH] transport: don't flush when disconnecting stateless-rpc helper Jeff King
2020-01-08 12:44 ` brian m. carlson
2020-01-08 13:43 ` Derrick Stolee [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=bc8f8c12-75d0-c79c-2778-0e7afe6b796a@gmail.com \
--to=stolee@gmail.com \
--cc=git@vger.kernel.org \
--cc=jonathantanmy@google.com \
--cc=peff@peff.net \
--cc=sandals@crustytoothpaste.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).