git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Jeff King <peff@peff.net>
Cc: Jim Meyering <jim@meyering.net>, git list <git@vger.kernel.org>
Subject: Re: [PATCH] read_in_full: always report errors
Date: Thu, 26 May 2011 11:35:51 -0700	[thread overview]
Message-ID: <7vy61twbqw.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: <20110526163027.GC4049@sigill.intra.peff.net> (Jeff King's message of "Thu, 26 May 2011 12:30:27 -0400")

Jeff King <peff@peff.net> writes:

> Subject: [PATCH] read_in_full: always report errors
>
> The read_in_full function repeatedly calls read() to fill a
> buffer. If the first read() returns an error, we notify the
> caller by returning the error. However, if we read some data
> and then get an error on a subsequent read, we simply return
> the amount of data that we did read, and the caller is
> unaware of the error.

Is the caller unaware?  While it won't hurt the callers who do:

   if (expect != read_in_full(fd, buf, expect))
      die(...)

I think this change hurts the one that you mentioned in your analysis.

The caller in index_stream() reads what it could, writes what it read, and
comes back and makes another call to read_in_full(), at which point either
it gets an error and the whole thing would error out (i.e. no difference
from before), or if it was an transient error that interrupted the
previous read_in_full(), it can keep reading (with this patch it will not
have a chance to do so).

> This makes the tradeoff that seeing the partial data is more
> important than the fact that an error occurred. In practice,
> this is generally not the case; we care more if an error
> occurred, and should throw away any partial data.

Not really. I think we care about both, and I think that is what the
current code tries to do.

  reply	other threads:[~2011-05-26 18:36 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-26 13:59 [PATCH] remove unnecessary test and dead diagnostic Jim Meyering
2011-05-26 14:11 ` Jeff King
2011-05-26 14:34   ` Jim Meyering
2011-05-26 16:28     ` Jeff King
2011-05-26 14:37   ` Jim Meyering
2011-05-26 16:30     ` [PATCH] read_in_full: always report errors Jeff King
2011-05-26 18:35       ` Junio C Hamano [this message]
2011-05-26 18:48         ` Jeff King
2011-05-26 20:53           ` Junio C Hamano
2011-05-26 21:04             ` Jeff King

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=7vy61twbqw.fsf@alter.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=jim@meyering.net \
    --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).