diff options
author | Raghavendra G <raghavendra@zresearch.com> | 2009-06-10 07:00:59 +0000 |
---|---|---|
committer | Anand V. Avati <avati@dev.gluster.com> | 2009-06-30 14:36:25 -0700 |
commit | 344319ab62daccac38592df30417d706836afb74 (patch) | |
tree | f3add5e38f96f2b46aafd636e206204d1fdbcf04 /libglusterfsclient | |
parent | 67f30aed943b13956e3a0e78f4a1f74fa05bc1fd (diff) |
libglusterfsclient: update offset in glusterfs_read_async_cbk only if offset stored in fd_ctx is used.
- this helps in implementing sendfile(2). manpage says that
"If offset is not NULL, then sendfile() does not modify the current
file offset of in_fd"
Signed-off-by: Anand V. Avati <avati@dev.gluster.com>
Diffstat (limited to 'libglusterfsclient')
-rwxr-xr-x | libglusterfsclient/src/libglusterfsclient-internals.h | 1 | ||||
-rwxr-xr-x | libglusterfsclient/src/libglusterfsclient.c | 13 |
2 files changed, 10 insertions, 4 deletions
diff --git a/libglusterfsclient/src/libglusterfsclient-internals.h b/libglusterfsclient/src/libglusterfsclient-internals.h index d55cfb1f5f6..9b14dcb9153 100755 --- a/libglusterfsclient/src/libglusterfsclient-internals.h +++ b/libglusterfsclient/src/libglusterfsclient-internals.h @@ -131,6 +131,7 @@ typedef struct libglusterfs_client_async_local { struct { fd_t *fd; glusterfs_readv_cbk_t cbk; + char update_offset; }readv_cbk; struct { diff --git a/libglusterfsclient/src/libglusterfsclient.c b/libglusterfsclient/src/libglusterfsclient.c index 107d8dbc590..36189aaa1b9 100755 --- a/libglusterfsclient/src/libglusterfsclient.c +++ b/libglusterfsclient/src/libglusterfsclient.c @@ -3709,11 +3709,15 @@ libglusterfs_readv_async_cbk (call_frame_t *frame, if (op_ret > 0) { libglusterfs_client_fd_ctx_t *fd_ctx = NULL; fd_ctx = libgf_get_fd_ctx (__fd); - pthread_mutex_lock (&fd_ctx->lock); - { - fd_ctx->offset += op_ret; + + /* update offset only if we have used offset stored in fd_ctx */ + if (local->fop.readv_cbk.update_offset) { + pthread_mutex_lock (&fd_ctx->lock); + { + fd_ctx->offset += op_ret; + } + pthread_mutex_unlock (&fd_ctx->lock); } - pthread_mutex_unlock (&fd_ctx->lock); } readv_cbk (op_ret, op_errno, buf, local->cbk_data); @@ -3780,6 +3784,7 @@ glusterfs_read_async (glusterfs_file_t fd, pthread_mutex_lock (&fd_ctx->lock); { offset = fd_ctx->offset; + local->fop.readv_cbk.update_offset = 1; } pthread_mutex_unlock (&fd_ctx->lock); } |