From: Junio C Hamano <gitster@pobox.com>
To: Jiang Xin <worldhello.net@gmail.com>
Cc: Git List <git@vger.kernel.org>,
Brandon Williams <bwilliams.eng@gmail.com>,
Ilari Liusvaara <ilari.liusvaara@elisanet.fi>,
Jiang Xin <zhiyou.jx@alibaba-inc.com>
Subject: Re: [PATCH v2 2/3] transport-helper: run do_take_over in connect_helper
Date: Mon, 25 Sep 2023 14:34:35 -0700 [thread overview]
Message-ID: <xmqqil7yq6ms.fsf@gitster.g> (raw)
In-Reply-To: <20230923152201.14741-3-worldhello.net@gmail.com> (Jiang Xin's message of "Sat, 23 Sep 2023 23:22:00 +0800")
Jiang Xin <worldhello.net@gmail.com> writes:
> From: Jiang Xin <zhiyou.jx@alibaba-inc.com>
>
> After successfully connecting to the smart transport by calling
> "process_connect_service()" in "connect_helper()", run "do_take_over()"
> to replace the old vtable with a new one which has methods ready for
> the smart transport connection.
The existing pattern among all callers of process_connect() seems to
be
if (process_connect(...)) {
do_take_over();
... dispatch to the underlying method ...
}
... otherwise implement the fallback ...
where the return value from process_connect() is the return value of
the call it makes to process_connect_service().
And the only other caller of process_connect_service() is
connect_helper(), so in that sense, making a call to do_take_over()
when process_connect_service() succeeds in the helper does make
things consistent. The connect_helper() function being static, the
helper transport is the only transport that gets affected, but how
has it been working without having this do_take_over() step? An
obvious related question is if it has been working so far, would it
break if we have do_take_over() added here?
In any case, this makes me wonder if we should do the following
patch to help developers who may want to add new callers to
process_connect_service() by adding calls to process_connect().
transport-helper.c | 22 +++++++++-------------
1 file changed, 9 insertions(+), 13 deletions(-)
diff --git c/transport-helper.c w/transport-helper.c
index 91381be622..566f7473df 100644
--- c/transport-helper.c
+++ w/transport-helper.c
@@ -646,6 +646,7 @@ static int process_connect(struct transport *transport,
struct helper_data *data = transport->data;
const char *name;
const char *exec;
+ int ret;
name = for_push ? "git-receive-pack" : "git-upload-pack";
if (for_push)
@@ -653,7 +654,10 @@ static int process_connect(struct transport *transport,
else
exec = data->transport_options.uploadpack;
- return process_connect_service(transport, name, exec);
+ ret = process_connect_service(transport, name, exec);
+ if (ret)
+ do_take_over(transport);
+ return ret;
}
static int connect_helper(struct transport *transport, const char *name,
@@ -685,10 +689,8 @@ static int fetch_refs(struct transport *transport,
get_helper(transport);
- if (process_connect(transport, 0)) {
- do_take_over(transport);
+ if (process_connect(transport, 0))
return transport->vtable->fetch_refs(transport, nr_heads, to_fetch);
- }
/*
* If we reach here, then the server, the client, and/or the transport
@@ -1145,10 +1147,8 @@ static int push_refs(struct transport *transport,
{
struct helper_data *data = transport->data;
- if (process_connect(transport, 1)) {
- do_take_over(transport);
+ if (process_connect(transport, 1))
return transport->vtable->push_refs(transport, remote_refs, flags);
- }
if (!remote_refs) {
fprintf(stderr,
@@ -1189,11 +1189,9 @@ static struct ref *get_refs_list(struct transport *transport, int for_push,
{
get_helper(transport);
- if (process_connect(transport, for_push)) {
- do_take_over(transport);
+ if (process_connect(transport, for_push))
return transport->vtable->get_refs_list(transport, for_push,
transport_options);
- }
return get_refs_list_using_list(transport, for_push);
}
@@ -1277,10 +1275,8 @@ static int get_bundle_uri(struct transport *transport)
{
get_helper(transport);
- if (process_connect(transport, 0)) {
- do_take_over(transport);
+ if (process_connect(transport, 0))
return transport->vtable->get_bundle_uri(transport);
- }
return -1;
}
next prev parent reply other threads:[~2023-09-25 21:34 UTC|newest]
Thread overview: 61+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-19 6:41 [PATCH 1/2] transport-helper: no connection restriction in connect_helper Jiang Xin
2023-09-19 6:41 ` [PATCH 2/2] archive: support remote archive from stateless transport Jiang Xin
2023-09-19 17:18 ` [PATCH 1/2] transport-helper: no connection restriction in connect_helper Junio C Hamano
2023-09-20 0:20 ` Jiang Xin
2023-09-23 15:21 ` [PATCH v2 0/3] support remote archive from stateless transport Jiang Xin
2023-09-25 22:21 ` Junio C Hamano
2023-09-26 0:43 ` Jiang Xin
2023-09-23 15:21 ` [PATCH v2 1/3] transport-helper: no connection restriction in connect_helper Jiang Xin
2023-09-25 21:11 ` Junio C Hamano
2023-09-23 15:22 ` [PATCH v2 2/3] transport-helper: run do_take_over " Jiang Xin
2023-09-25 21:34 ` Junio C Hamano [this message]
2023-10-04 14:00 ` Jiang Xin
2023-10-04 15:21 ` [PATCH v3 0/4] support remote archive from stateless transport Jiang Xin
2023-10-04 15:21 ` [PATCH v3 1/4] transport-helper: no connection restriction in connect_helper Jiang Xin
2023-10-04 15:21 ` [PATCH v3 2/4] transport-helper: call do_take_over() in process_connect Jiang Xin
2023-10-04 18:29 ` Junio C Hamano
2023-10-04 15:21 ` [PATCH v3 3/4] transport-helper: call do_take_over() in connect_helper Jiang Xin
2023-10-04 15:21 ` [PATCH v3 4/4] archive: support remote archive from stateless transport Jiang Xin
2023-12-14 14:13 ` [PATCH v4 0/4] support remote archive via " Jiang Xin
2023-12-14 14:13 ` [PATCH v4 1/4] transport-helper: no connection restriction in connect_helper Jiang Xin
2024-01-12 7:42 ` Linus Arver
2024-01-12 21:50 ` Junio C Hamano
2024-01-16 9:04 ` Jiang Xin
2024-01-18 22:26 ` Linus Arver
2024-01-19 10:56 ` Jiang Xin
2024-01-20 20:25 ` Linus Arver
2023-12-14 14:13 ` [PATCH v4 2/4] transport-helper: call do_take_over() in process_connect Jiang Xin
2023-12-14 14:13 ` [PATCH v4 3/4] transport-helper: call do_take_over() in connect_helper Jiang Xin
2024-01-12 7:56 ` Linus Arver
2024-01-16 9:41 ` Jiang Xin
2023-12-14 14:13 ` [PATCH v4 4/4] archive: support remote archive from stateless transport Jiang Xin
2024-01-12 8:12 ` Linus Arver
2024-01-16 13:39 ` [PATCH v5 0/6] support remote archive via " Jiang Xin
2024-01-16 13:39 ` [PATCH v5 1/6] transport-helper: no connection restriction in connect_helper Jiang Xin
2024-01-20 20:28 ` Linus Arver
2024-01-16 13:39 ` [PATCH v5 2/6] remote-curl: supports git-upload-archive service Jiang Xin
2024-01-20 20:30 ` Linus Arver
2024-01-16 13:39 ` [PATCH v5 3/6] transport-helper: protocol-v2 supports upload-archive Jiang Xin
2024-01-16 13:39 ` [PATCH v5 4/6] http-backend: new rpc-service for git-upload-archive Jiang Xin
2024-01-16 13:39 ` [PATCH v5 5/6] transport-helper: call do_take_over() in connect_helper Jiang Xin
2024-01-20 20:37 ` Linus Arver
2024-01-16 13:39 ` [PATCH v5 6/6] transport-helper: call do_take_over() in process_connect Jiang Xin
2024-01-20 20:43 ` [PATCH v5 0/6] support remote archive via stateless transport Linus Arver
2024-01-21 4:09 ` Jiang Xin
2024-01-21 13:15 ` [PATCH v6 " Jiang Xin
2024-01-21 13:15 ` [PATCH v6 1/6] transport-helper: no connection restriction in connect_helper Jiang Xin
2024-01-21 13:15 ` [PATCH v6 2/6] remote-curl: supports git-upload-archive service Jiang Xin
2024-01-21 13:15 ` [PATCH v6 3/6] transport-helper: protocol v2 supports upload-archive Jiang Xin
2024-01-21 13:15 ` [PATCH v6 4/6] http-backend: new rpc-service for git-upload-archive Jiang Xin
2024-01-21 13:15 ` [PATCH v6 5/6] transport-helper: call do_take_over() in connect_helper Jiang Xin
2024-01-21 13:15 ` [PATCH v6 6/6] transport-helper: call do_take_over() in process_connect Jiang Xin
2024-01-21 16:57 ` [PATCH v6 0/6] support remote archive via stateless transport Linus Arver
2024-01-22 15:54 ` Junio C Hamano
2023-09-23 15:22 ` [PATCH v2 3/3] archive: support remote archive from " Jiang Xin
2023-09-24 6:52 ` Eric Sunshine
2023-09-24 23:39 ` Jiang Xin
2023-09-24 23:58 ` rsbecker
2023-09-25 0:15 ` Jiang Xin
2023-09-25 1:04 ` rsbecker
2023-09-24 13:41 ` Phillip Wood
2023-09-24 23:36 ` Jiang Xin
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqil7yq6ms.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=bwilliams.eng@gmail.com \
--cc=git@vger.kernel.org \
--cc=ilari.liusvaara@elisanet.fi \
--cc=worldhello.net@gmail.com \
--cc=zhiyou.jx@alibaba-inc.com \
/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.
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 NNTP newsgroup(s).