From: "Shawn O. Pearce" <spearce@spearce.org>
To: Bill Lear <rael@zopyra.com>
Cc: git@vger.kernel.org
Subject: Re: Error "fatal: cannot pread pack file: Success"
Date: Tue, 27 Feb 2007 23:47:19 -0500 [thread overview]
Message-ID: <20070228044719.GA6068@spearce.org> (raw)
In-Reply-To: <20070228035713.GC5597@spearce.org>
"Shawn O. Pearce" <spearce@spearce.org> wrote:
> Bill Lear <rael@zopyra.com> wrote:
> > Using 1.5.0.1. Can't see what is wrong with this clone...
> ...
> > Indexing 4589 objects.
> > remote: Total 4589 (delta 2209), reused 4589 (delta 2209)
> > 100% (4589/4589) done
> > Resolving 2209 deltas.
> > fatal: cannot pread pack file: Success
> > fatal: index-pack died with error code 128
> > fetch-pack from '/home/rael/devel/project/.git' failed.
>
> I think the pread() in get_data_from_pack of index-pack is wrong,
> it really should be looping until we fill the buffer in case the
> OS doesn't fully satisfy our read request the first time.
Does this fix your problem?
-->8--
[PATCH] index-pack: Loop over pread until data loading is complete.
A filesystem might not be able to completely supply our pread
request in one system call, such as if we are reading data from a
network file system and the requested length is just simply huge.
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
---
index-pack.c | 10 ++++++++--
1 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/index-pack.c b/index-pack.c
index 859ec01..cf81a99 100644
--- a/index-pack.c
+++ b/index-pack.c
@@ -277,13 +277,19 @@ static void *get_data_from_pack(struct object_entry *obj)
{
unsigned long from = obj[0].offset + obj[0].hdr_size;
unsigned long len = obj[1].offset - from;
+ unsigned long rdy = 0;
unsigned char *src, *data;
z_stream stream;
int st;
src = xmalloc(len);
- if (pread(pack_fd, src, len, from) != len)
- die("cannot pread pack file: %s", strerror(errno));
+ data = src;
+ do {
+ ssize_t n = pread(pack_fd, data + rdy, len - rdy, from + rdy);
+ if (n <= 0)
+ die("cannot pread pack file: %s", strerror(errno));
+ rdy += n;
+ } while (rdy < len);
data = xmalloc(obj->size);
memset(&stream, 0, sizeof(stream));
stream.next_out = data;
--
1.5.0.2.775.g1a500
--
Shawn.
next prev parent reply other threads:[~2007-02-28 4:47 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-02-28 3:45 Error "fatal: cannot pread pack file: Success" Bill Lear
2007-02-28 3:57 ` Shawn O. Pearce
2007-02-28 4:47 ` Shawn O. Pearce [this message]
2007-02-28 5:55 ` Junio C Hamano
2007-02-28 15:47 ` Linus Torvalds
2007-02-28 15:28 ` Bill Lear
2007-02-28 15:48 ` Bill Lear
2007-02-28 15:54 ` Shawn O. Pearce
2007-02-28 16:12 ` Bill Lear
2007-02-28 16:23 ` Bill Lear
2007-02-28 16:32 ` Shawn O. Pearce
2007-02-28 16:40 ` Bill Lear
2007-02-28 16:48 ` Shawn O. Pearce
2007-02-28 16:42 ` Morten Welinder
2007-02-28 16:49 ` Shawn O. Pearce
2007-02-28 16:55 ` Bill Lear
2007-02-28 17:06 ` Shawn O. Pearce
2007-02-28 17:10 ` Bill Lear
2007-02-28 17:43 ` Shawn O. Pearce
2007-02-28 17:50 ` Nicolas Pitre
2007-02-28 17:58 ` Shawn O. Pearce
2007-02-28 19:18 ` Bill Lear
2007-02-28 19:23 ` Bill Lear
2007-02-28 19:40 ` Nicolas Pitre
2007-03-01 15:23 ` Bill Lear
2007-02-28 16:34 ` Linus Torvalds
2007-02-28 16:36 ` Bill Lear
2007-02-28 16:47 ` Linus Torvalds
2007-02-28 16:52 ` Bill Lear
2007-02-28 17:13 ` Linus Torvalds
2007-02-28 18:18 ` Nicolas Pitre
2007-02-28 18:37 ` Linus Torvalds
[not found] ` <17893.53091.452962.414271@lisa.zopyra.com>
2007-02-28 19:22 ` Linus Torvalds
2007-02-28 17:42 ` Nicolas Pitre
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=20070228044719.GA6068@spearce.org \
--to=spearce@spearce.org \
--cc=git@vger.kernel.org \
--cc=rael@zopyra.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).