From 329f423b4779e41a1c3d0b280aea5ffc40a75fc9 Mon Sep 17 00:00:00 2001 From: Raghavendra G Date: Tue, 12 Jan 2010 17:41:27 +0000 Subject: libglusterfsclient/read: fix data corruption. - libgf_client_read(v) should return the total number of bytes read by multiple invocations of libgf_client_iobuf_read(v), instead of return value of last invocation. Signed-off-by: Raghavendra G Signed-off-by: Anand V. Avati BUG: 531 (accessing a file through apache results in Permission denied errors.) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=531 --- libglusterfsclient/src/libglusterfsclient.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/libglusterfsclient/src/libglusterfsclient.c b/libglusterfsclient/src/libglusterfsclient.c index 1392f4b22..e0fdc6a4d 100755 --- a/libglusterfsclient/src/libglusterfsclient.c +++ b/libglusterfsclient/src/libglusterfsclient.c @@ -3613,7 +3613,7 @@ int libgf_client_read (libglusterfs_client_ctx_t *ctx, fd_t *fd, void *buf, size_t size, off_t offset) { - int32_t op_ret = -1; + int32_t op_ret = -1, ret = 0; size_t tmp = 0; while (size != 0) { @@ -3627,9 +3627,10 @@ libgf_client_read (libglusterfs_client_ctx_t *ctx, fd_t *fd, void *buf, size -= op_ret; offset += op_ret; buf = (char *)buf + op_ret; + ret += op_ret; } - return op_ret; + return ret; } ssize_t @@ -3757,7 +3758,7 @@ ssize_t libgf_client_readv (libglusterfs_client_ctx_t *ctx, fd_t *fd, const struct iovec *dst_vector, int dst_count, off_t offset) { - int32_t op_ret = -1; + int32_t op_ret = -1, ret = 0; size_t size = 0, tmp = 0; int i = 0; int dst_idx = 0; @@ -3779,9 +3780,10 @@ libgf_client_readv (libglusterfs_client_ctx_t *ctx, fd_t *fd, offset += op_ret; size -= op_ret; + ret += op_ret; } - return op_ret; + return ret; } -- cgit