summaryrefslogtreecommitdiffstats
path: root/libglusterfsclient
diff options
context:
space:
mode:
Diffstat (limited to 'libglusterfsclient')
-rwxr-xr-xlibglusterfsclient/src/libglusterfsclient-internals.h5
-rwxr-xr-xlibglusterfsclient/src/libglusterfsclient.c18
2 files changed, 16 insertions, 7 deletions
diff --git a/libglusterfsclient/src/libglusterfsclient-internals.h b/libglusterfsclient/src/libglusterfsclient-internals.h
index fc79a539d69..d55cfb1f5f6 100755
--- a/libglusterfsclient/src/libglusterfsclient-internals.h
+++ b/libglusterfsclient/src/libglusterfsclient-internals.h
@@ -64,6 +64,11 @@ typedef struct {
int32_t size;
} lookup;
}fop;
+ fd_t *dirfd; /* Needed here because we need a ref to the dir
+ fd in the libgf_client_readdir_cbk in order
+ to process the dirents received, without
+ having them added to the reply stub.
+ */
}libgf_client_local_t;
typedef struct {
diff --git a/libglusterfsclient/src/libglusterfsclient.c b/libglusterfsclient/src/libglusterfsclient.c
index c05918e2148..9399d2c29b4 100755
--- a/libglusterfsclient/src/libglusterfsclient.c
+++ b/libglusterfsclient/src/libglusterfsclient.c
@@ -3489,9 +3489,15 @@ libgf_client_readdir_cbk (call_frame_t *frame,
{
libgf_client_local_t *local = frame->local;
+ /* Note, we dont let entries reach the stub because there it gets copied
+ * while we can simply delink the entries here and link them into our
+ * dcache, thereby avoiding the need to perform more allocations and
+ * copies.
+ */
local->reply_stub = fop_readdir_cbk_stub (frame, NULL, op_ret, op_errno,
- entries);
-
+ NULL);
+ if (op_ret > 0)
+ libgf_dcache_update (frame->root->state, local->dirfd, entries);
LIBGF_REPLY_NOTIFY (local);
return 0;
}
@@ -3506,16 +3512,14 @@ libgf_client_readdir (libglusterfs_client_ctx_t *ctx, fd_t *fd,
if (libgf_dcache_readdir (ctx, fd, dirp, offset))
return 1;
-
+ local = CALLOC (1, sizeof (*local));
+ ERR_ABORT (local);
+ local->dirfd = fd;
LIBGF_CLIENT_FOP (ctx, stub, readdir, local, fd,
LIBGF_READDIR_BLOCK, *offset);
- op_ret = stub->args.readdir_cbk.op_ret;
errno = stub->args.readdir_cbk.op_errno;
- if (op_ret > 0)
- libgf_dcache_update (ctx, fd, &stub->args.readdir_cbk.entries);
-
op_ret = libgf_dcache_readdir (ctx, fd, dirp, offset);
call_stub_destroy (stub);
return op_ret;