From c99c72b35fac16e08c4d170b6a46a786caaeef58 Mon Sep 17 00:00:00 2001 From: Poornima G Date: Mon, 16 Mar 2015 15:47:30 +0530 Subject: libgfapi, timer: Fix a crash seen in timer when glfs_fini was invoked. The crash is seen when, glfs_init failed for some reason and glfs_fini was called for cleaning up the partial initialization. The fix is in two folds: 1. In timer store and restore the THIS, previously it was being overwritten. 2. In glfs_free_from_ctx() and glfs_fini() check for NULL before destroying. Change-Id: If40bf69936b873a1da8e348c9d92c66f2f07994b BUG: 1202290 Signed-off-by: Poornima G Reviewed-on: http://review.gluster.org/9895 Reviewed-by: Raghavendra Talur Reviewed-by: Krishnan Parthasarathi Reviewed-by: Raghavendra Bhat Tested-by: Gluster Build System Reviewed-by: Vijay Bellur --- libglusterfs/src/timer.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'libglusterfs/src/timer.c') diff --git a/libglusterfs/src/timer.c b/libglusterfs/src/timer.c index 928b3681c89..cc47db3b9e1 100644 --- a/libglusterfs/src/timer.c +++ b/libglusterfs/src/timer.c @@ -141,6 +141,7 @@ gf_timer_proc (void *ctx) gf_timer_registry_t *reg = NULL; const struct timespec sleepts = {.tv_sec = 1, .tv_nsec = 0, }; gf_timer_t *event = NULL; + xlator_t *old_THIS = NULL; if (ctx == NULL) { @@ -174,11 +175,16 @@ gf_timer_proc (void *ctx) } } pthread_mutex_unlock (®->lock); - if (event->xl) - THIS = event->xl; - if (need_cbk) - event->callbk (event->data); - + if (need_cbk) { + if (event->xl) { + old_THIS = THIS; + THIS = event->xl; + } + event->callbk (event->data); + if (event->xl) { + THIS = old_THIS; + } + } else break; } -- cgit