summaryrefslogtreecommitdiffstats
path: root/libglusterfsclient
diff options
context:
space:
mode:
authorShehjar Tikoo <shehjart@zresearch.com>2009-04-16 23:53:39 -0700
committerAnand V. Avati <avati@amp.gluster.com>2009-04-17 13:42:51 +0530
commitc71110fb153adfd4628718f634348b7a5712bf32 (patch)
tree4d2551bc6f7f4977fad75be2f044d564f00d093f /libglusterfsclient
parentadb677be13e6b755c3eeb685759d2522f6c466a7 (diff)
libglusterfsclient: Fix fd_ctx leak on release cbks
Signed-off-by: Anand V. Avati <avati@amp.gluster.com>
Diffstat (limited to 'libglusterfsclient')
-rwxr-xr-xlibglusterfsclient/src/libglusterfsclient.c32
1 files changed, 27 insertions, 5 deletions
diff --git a/libglusterfsclient/src/libglusterfsclient.c b/libglusterfsclient/src/libglusterfsclient.c
index 8d337e7d22e..ee32cfe415c 100755
--- a/libglusterfsclient/src/libglusterfsclient.c
+++ b/libglusterfsclient/src/libglusterfsclient.c
@@ -158,25 +158,47 @@ out:
return fdctx;
}
+libglusterfs_client_fd_ctx_t *
+libgf_del_fd_ctx (fd_t *fd)
+{
+ uint64_t ctxaddr = 0;
+ libglusterfs_client_fd_ctx_t *ctx = NULL;
+
+ GF_VALIDATE_OR_GOTO (LIBGF_XL_NAME, fd, out);
+
+ if (fd_ctx_del (fd, libgf_fd_to_xlator (fd) , &ctxaddr) == -1)
+ goto out;
+
+ ctx = (libglusterfs_client_fd_ctx_t *)(long)ctxaddr;
+
+out:
+ return ctx;
+}
+
int32_t
libgf_client_release (xlator_t *this,
fd_t *fd)
{
libglusterfs_client_fd_ctx_t *fd_ctx = NULL;
- fd_ctx = libgf_get_fd_ctx (fd);
- pthread_mutex_destroy (&fd_ctx->lock);
+ fd_ctx = libgf_del_fd_ctx (fd);
+ if (fd_ctx != NULL) {
+ pthread_mutex_destroy (&fd_ctx->lock);
+ FREE (fd_ctx);
+ }
return 0;
}
-
int32_t
libgf_client_releasedir (xlator_t *this,
fd_t *fd)
{
libglusterfs_client_fd_ctx_t *fd_ctx = NULL;
- fd_ctx = libgf_get_fd_ctx (fd);
- pthread_mutex_destroy (&fd_ctx->lock);
+ fd_ctx = libgf_del_fd_ctx (fd);
+ if (fd_ctx != NULL) {
+ pthread_mutex_destroy (&fd_ctx->lock);
+ FREE (fd_ctx);
+ }
return 0;
}