aboutsummaryrefslogtreecommitdiff
path: root/index-pack.c
diff options
context:
space:
mode:
authorShawn O. Pearce <spearce@spearce.org>2007-02-27 23:47:19 -0500
committerJunio C Hamano <junkio@cox.net>2007-02-27 21:58:46 -0800
commita91d49cd369ac5fc8e1a17357a975d09cf6c8cb3 (patch)
treea9118b5ee5a5b457ef95902a34044d73a5a9b21e /index-pack.c
parentae648606220c55074dfa12d1a11f60e62a7254ac (diff)
downloadgit-a91d49cd369ac5fc8e1a17357a975d09cf6c8cb3.tar.gz
git-a91d49cd369ac5fc8e1a17357a975d09cf6c8cb3.tar.xz
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> Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'index-pack.c')
-rw-r--r--index-pack.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/index-pack.c b/index-pack.c
index 72e096241..f9177442a 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;