All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: James Cloos <cloos@jhcloos.com>
Cc: Nicolas Pitre <nico@cam.org>, git@vger.kernel.org
Subject: Re: [PATCH 1/1] Improve progress display in kB range.
Date: Wed, 22 Apr 2009 12:44:05 -0700	[thread overview]
Message-ID: <7vljps324a.fsf@gitster.siamese.dyndns.org> (raw)
In-Reply-To: <m34owgoj08.fsf@lugabout.jhcloos.org> (James Cloos's message of "Wed, 22 Apr 2009 10:33:19 -0400")

James Cloos <cloos@jhcloos.com> writes:

> |> Therefore, in practice — and as I have witnessed several thousand times
> |> without ever having seen a contrary example — display_throughput() is
> |> called *durring* a download only when total & 0xFFF == 0xFFF.
>
> Another possibility is an off-by-one error.  The relevant part of fill()
> looks like:
>
> ,----< excerpt from index-pack.c:fill() >
> |   do {
> |     ssize_t ret = xread(input_fd, input_buffer + input_len,
> |                         sizeof(input_buffer) - input_len);
> |     if (ret <= 0) {
> |       if (!ret)
> |         die("early EOF");
> |       die("read error on input: %s", strerror(errno));
> |     }
> |     input_len += ret;
> |     if (from_stdin)
> |       display_throughput(progress, consumed_bytes + input_len);
> |   } while (input_len < min);
> |   return input_buffer;
> | }
> `----
>
> if *(input_buffer + ret) is the last read octet rather than the next
> empty octet, that would also explain what I see.

After checking "ret" from xread(), input_len is incremented by that
amount, and the next iteration gives "input_buffer + input_len" to
xread().  If input_buffer[ret] _were_ the last octet read, your loop would
be discarding that octet when you call more than one xread() to fill the
buffer.

  reply	other threads:[~2009-04-22 19:45 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-04-19  4:38 [PATCH 0/1] Improve progress display in kB range James Cloos
2009-04-19  4:32 ` [PATCH 1/1] " James Cloos
2009-04-21  4:56   ` Nicolas Pitre
2009-04-21 17:11     ` James Cloos
2009-04-21 17:28       ` Nicolas Pitre
2009-04-21 20:16         ` James Cloos
2009-04-22 14:33           ` James Cloos
2009-04-22 19:44             ` Junio C Hamano [this message]
2009-04-22 22:35               ` James Cloos
2009-04-23  6:23                 ` Johannes Sixt
2009-04-24 20:15                 ` James Cloos
2009-04-24 21:46                   ` Nicolas Pitre
2009-04-24 22:20                     ` James Cloos

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=7vljps324a.fsf@gitster.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=cloos@jhcloos.com \
    --cc=git@vger.kernel.org \
    --cc=nico@cam.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.