From 34e6028e4ceaff5ceb1165317a3a90d02e0da4ac Mon Sep 17 00:00:00 2001 From: Mohammed Rafi KC Date: Wed, 23 Jan 2019 21:55:01 +0530 Subject: clnt/rpc: ref leak during disconnect. During disconnect cleanup, we are not cancelling reconnect timer, which causes a ref leak each time when a disconnect happen. Change-Id: I9d05d1f368d080e04836bf6a0bb018bf8f7b5b8a updates: bz#1659708 Signed-off-by: Mohammed Rafi KC --- libglusterfs/src/timer.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'libglusterfs') diff --git a/libglusterfs/src/timer.c b/libglusterfs/src/timer.c index d882543b08b..2643c07820b 100644 --- a/libglusterfs/src/timer.c +++ b/libglusterfs/src/timer.c @@ -75,13 +75,13 @@ gf_timer_call_cancel(glusterfs_ctx_t *ctx, gf_timer_t *event) if (ctx == NULL || event == NULL) { gf_msg_callingfn("timer", GF_LOG_ERROR, EINVAL, LG_MSG_INVALID_ARG, "invalid argument"); - return 0; + return -1; } if (ctx->cleanup_started) { gf_msg_callingfn("timer", GF_LOG_INFO, 0, LG_MSG_CTX_CLEANUP_STARTED, "ctx cleanup started"); - return 0; + return -1; } LOCK(&ctx->lock); @@ -93,10 +93,9 @@ gf_timer_call_cancel(glusterfs_ctx_t *ctx, gf_timer_t *event) if (!reg) { /* This can happen when cleanup may have just started and * gf_timer_registry_destroy() sets ctx->timer to NULL. - * Just bail out as success as gf_timer_proc() takes - * care of cleaning up the events. + * gf_timer_proc() takes care of cleaning up the events. */ - return 0; + return -1; } LOCK(®->lock); @@ -203,6 +202,13 @@ gf_timer_proc(void *data) list_for_each_entry_safe(event, tmp, ®->active, list) { list_del(&event->list); + /* TODO Possible resource leak + * Before freeing the event, we need to call the respective + * event functions and free any resources. + * For example, In case of rpc_clnt_reconnect, we need to + * unref rpc object which was taken when added to timer + * wheel. + */ GF_FREE(event); } } -- cgit