summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRaghavendra G <raghavendra@gluster.com>2010-01-12 17:41:27 +0000
committerAnand V. Avati <avati@dev.gluster.com>2010-01-14 23:23:57 -0800
commit329f423b4779e41a1c3d0b280aea5ffc40a75fc9 (patch)
treefabb94540b518957c4a0047d63a8b6870811d95a
parente700afa8ebbb345657a8351e00814a7bdd8b3dff (diff)
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 <raghavendra@gluster.com> Signed-off-by: Anand V. Avati <avati@dev.gluster.com> 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
-rwxr-xr-xlibglusterfsclient/src/libglusterfsclient.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/libglusterfsclient/src/libglusterfsclient.c b/libglusterfsclient/src/libglusterfsclient.c
index 1392f4b22a4..e0fdc6a4d12 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;
}