summaryrefslogtreecommitdiffstats
path: root/libglusterfsclient
diff options
context:
space:
mode:
authorAnand Avati <avati@gluster.com>2009-12-06 04:44:59 +0000
committerAnand V. Avati <avati@dev.gluster.com>2009-12-06 02:30:28 -0800
commit7a3c372c7a8a3ad7d481f94a899fd4333d146634 (patch)
tree6d12c84ba474341d6cf5001d270e01cc36d51b90 /libglusterfsclient
parent4235868f0ded7aeb157aef05f10d2df4a470a2c5 (diff)
libglusterfsclient: fix libgf_client_read to handle short reads
Fixes two issues in the current code -short reads (reading larger than file size) result in failure of full read -reads which span multiple iterations return with the op_ret of only the last read Signed-off-by: Anand V. Avati <avati@blackhole.gluster.com> Signed-off-by: Anand V. Avati <avati@dev.gluster.com> BUG: 334 (glusterfs_read/readv should break large-reads into 128Kb block sizes) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=334
Diffstat (limited to 'libglusterfsclient')
-rwxr-xr-xlibglusterfsclient/src/libglusterfsclient.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/libglusterfsclient/src/libglusterfsclient.c b/libglusterfsclient/src/libglusterfsclient.c
index f90de48c3..692f46d92 100755
--- a/libglusterfsclient/src/libglusterfsclient.c
+++ b/libglusterfsclient/src/libglusterfsclient.c
@@ -3703,22 +3703,29 @@ 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 ret = 0;
size_t tmp = 0;
while (size != 0) {
tmp = ((size > LIBGF_IOBUF_SIZE) ? LIBGF_IOBUF_SIZE :
size);
op_ret = libgf_client_iobuf_read (ctx, fd, buf, tmp, offset);
- if (op_ret <= 0) {
+ if (op_ret < 0) {
+ ret = op_ret;
break;
}
+ ret += op_ret;
+
+ if (op_ret < tmp)
+ break;
+
size -= op_ret;
offset += op_ret;
buf = (char *)buf + op_ret;
}
- return op_ret;
+ return ret;
}
ssize_t