From 98b98d6cd7d94bfae5b4a7b54b04b59bf9381df9 Mon Sep 17 00:00:00 2001 From: Raghavendra G Date: Mon, 26 Mar 2012 18:36:29 +0530 Subject: libglusterfs/fd: ref fds while copying the fdentries. Change-Id: I8973ec5d9858adfbdd6efc7cd596cf5d5af0e3cb BUG: 767862 Signed-off-by: Raghavendra G Reviewed-on: http://review.gluster.com/3006 Tested-by: Gluster Build System Reviewed-by: Anand Avati --- libglusterfs/src/fd.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'libglusterfs') diff --git a/libglusterfs/src/fd.c b/libglusterfs/src/fd.c index 46b75cb1051..73c244a60a3 100644 --- a/libglusterfs/src/fd.c +++ b/libglusterfs/src/fd.c @@ -172,7 +172,7 @@ fdentry_t * __gf_fd_fdtable_copy_all_fds (fdtable_t *fdtable, uint32_t *count) { fdentry_t *fdentries = NULL; - size_t cpy = 0; + int i = 0; if (count == NULL) { gf_log_callingfn ("fd", GF_LOG_WARNING, "!count"); @@ -187,8 +187,11 @@ __gf_fd_fdtable_copy_all_fds (fdtable_t *fdtable, uint32_t *count) *count = fdtable->max_fds; - cpy = fdtable->max_fds * sizeof (fdentry_t); - memcpy ((void *)fdentries, (void *)fdtable->fdentries, cpy); + for (i = 0; i < fdtable->max_fds; i++) { + if (fdtable->fdentries[i].fd != NULL) { + fdentries[i].fd = fd_ref (fdtable->fdentries[i].fd); + } + } out: return fdentries; -- cgit