From: Stefan Beller <sbeller@google.com>
To: Jeff King <peff@peff.net>
Cc: "git@vger.kernel.org" <git@vger.kernel.org>
Subject: Re: [PATCH 12/12] receive-pack: send keepalives during quiet periods
Date: Fri, 15 Jul 2016 10:24:16 -0700 [thread overview]
Message-ID: <CAGZ79kbernZHx9SUG-_vbxy-g77_3ki1uc-21LCviwrH=aXp6w@mail.gmail.com> (raw)
In-Reply-To: <20160715104347.GL19271@sigill.intra.peff.net>
On Fri, Jul 15, 2016 at 3:43 AM, Jeff King <peff@peff.net> wrote:
>
> Signed-off-by: Jeff King <peff@peff.net>
Read-entirely-by Stefan ;)
Thanks!
> @@ -319,10 +331,60 @@ static void rp_error(const char *err, ...)
> static int copy_to_sideband(int in, int out, void *arg)
> {
> char data[128];
While looking at this code, do you think it is feasible to increase the
size of data[] to 1024 ? (The largest that is possible when
side-band, but no side-band-64k is given).
> + int keepalive_active = 0;
> +
> + if (keepalive_in_sec <= 0)
> + use_keepalive = KEEPALIVE_NEVER;
> + if (use_keepalive == KEEPALIVE_ALWAYS)
> + keepalive_active = 1;
> +
> while (1) {
> - ssize_t sz = xread(in, data, sizeof(data));
> + ssize_t sz;
> +
> + if (keepalive_active) {
> + struct pollfd pfd;
> + int ret;
> +
> + pfd.fd = in;
> + pfd.events = POLLIN;
> + ret = poll(&pfd, 1, 1000 * keepalive_in_sec);
> +
> + if (ret < 0) {
> + if (errno == EINTR)
> + continue;
> + else
> + break;
The method was short and concise, this adds a lot of lines.
Remembering d751dd11 (2016-07-10, hoist out handle_nonblock
function for xread and xwrite), do you think it would be reasonable to
put the whole poll handling into a dedicated function, maybe even reuse the
that function?
if (keepalive_active) {
if (wrapper_around_poll(&data_in) < 0) // handles EINTR internally
break;
if (!data_in)
send_keep_alive();
}
I am not sure if that makes this function more legible, just food for thought.
> + } else if (ret == 0) {
> + /* no data; send a keepalive packet */
> + static const char buf[] = "0005\1";
and the \1 is the first sideband. Why do we choose that sideband?
> + write_or_die(1, buf, sizeof(buf) - 1);
> + continue;
> + } /* else there is actual data to read */
"If there is data to read, we need to break the while(1), to actually
read the data?"
I got confused and needed to go back and read the actual code again,
would it make sense to rather have a loop here?
while (1) {
while(keepalive_active) {
if (wrapper_around_poll(&data_in) < 0) // handles EINTR internally
break;
if (!data_in)
send_keep_alive();
else
break;
}
sz = xread(in, data, sizeof(data));
if (sz <= 0)
break;
turn_on_keepalive_on_NUL(&data);
}
> + }
> +
> + sz = xread(in, data, sizeof(data));
> if (sz <= 0)
> break;
> +
> + if (use_keepalive == KEEPALIVE_AFTER_NUL && !keepalive_active) {
> + const char *p = memchr(data, '\0', sz);
> + if (p) {
> + /*
> + * The NUL tells us to start sending keepalives. Make
> + * sure we send any other data we read along
> + * with it.
> + */
> + keepalive_active = 1;
> + send_sideband(1, 2, data, p - data, use_sideband);
> + send_sideband(1, 2, p + 1, sz - (p - data + 1), use_sideband);
> + continue;
Oh, I see why the turn_on_keepalive_on_NUL doesn't work as well as I thought.
I wonder if we can use a better read function, that would stop reading at a NUL,
and return early instead?
next prev parent reply other threads:[~2016-07-15 17:24 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-15 10:25 [PATCH 0/12] push progress reporting and keepalives Jeff King
2016-07-15 10:26 ` [PATCH 01/12] check_everything_connected: always pass --quiet to rev-list Jeff King
2016-07-15 10:28 ` [PATCH 02/12] rev-list: add optional progress reporting Jeff King
2016-07-15 18:00 ` Junio C Hamano
2016-07-16 1:23 ` Jeff King
2016-07-15 10:28 ` [PATCH 03/12] check_everything_connected: convert to argv_array Jeff King
2016-07-15 10:30 ` [PATCH 04/12] check_everything_connected: use a struct with named options Jeff King
2016-07-15 18:13 ` Junio C Hamano
2016-07-16 1:24 ` Jeff King
2016-07-15 10:32 ` [PATCH 05/12] check_connected: relay errors to alternate descriptor Jeff King
2016-07-15 18:19 ` Junio C Hamano
2016-07-16 1:27 ` Jeff King
2016-07-15 10:32 ` [PATCH 06/12] check_connected: add progress flag Jeff King
2016-07-15 10:33 ` [PATCH 07/12] clone: use a real progress meter for connectivity check Jeff King
2016-07-15 10:34 ` [PATCH 08/12] index-pack: add flag for showing delta-resolution progress Jeff King
2016-07-15 10:35 ` [PATCH 09/12] receive-pack: turn on index-pack resolving progress Jeff King
2016-07-15 10:36 ` [PATCH 10/12] receive-pack: relay connectivity errors to sideband Jeff King
2016-07-15 10:36 ` [PATCH 11/12] receive-pack: turn on connectivity progress Jeff King
2016-07-15 10:43 ` [PATCH 12/12] receive-pack: send keepalives during quiet periods Jeff King
2016-07-15 17:24 ` Stefan Beller [this message]
2016-07-16 7:56 ` Jeff King
2016-07-19 5:28 ` Stefan Beller
2016-07-19 10:07 ` Jeff King
2016-07-19 16:05 ` Stefan Beller
2016-07-20 13:28 ` Jeff King
2016-07-15 19:18 ` Junio C Hamano
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='CAGZ79kbernZHx9SUG-_vbxy-g77_3ki1uc-21LCviwrH=aXp6w@mail.gmail.com' \
--to=sbeller@google.com \
--cc=git@vger.kernel.org \
--cc=peff@peff.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.
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).