summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPoornima G <pgurusid@redhat.com>2015-03-16 15:47:30 +0530
committerVijay Bellur <vbellur@redhat.com>2015-03-17 22:42:12 -0700
commitc99c72b35fac16e08c4d170b6a46a786caaeef58 (patch)
tree1644650ecac2e828a5201c7b2ec2e0bcef5f2ed4
parent33944a3eb3b589b1d309826b5f431497924ac3ae (diff)
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 <pgurusid@redhat.com> Reviewed-on: http://review.gluster.org/9895 Reviewed-by: Raghavendra Talur <rtalur@redhat.com> Reviewed-by: Krishnan Parthasarathi <kparthas@redhat.com> Reviewed-by: Raghavendra Bhat <raghavendra@redhat.com> Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Vijay Bellur <vbellur@redhat.com>
-rw-r--r--api/src/glfs.c13
-rw-r--r--libglusterfs/src/timer.c16
2 files changed, 21 insertions, 8 deletions
diff --git a/api/src/glfs.c b/api/src/glfs.c
index 02a8984f450..8bd410c716d 100644
--- a/api/src/glfs.c
+++ b/api/src/glfs.c
@@ -664,7 +664,9 @@ priv_glfs_free_from_ctx (struct glfs *fs)
(void) pthread_mutex_destroy (&fs->mutex);
- FREE (fs->volname);
+ if (fs->volname)
+ FREE (fs->volname);
+
FREE (fs);
}
@@ -934,13 +936,17 @@ pub_glfs_fini (struct glfs *fs)
}
ctx = fs->ctx;
+ if (!ctx) {
+ goto free_fs;
+ }
+
+ __glfs_entry_fs (fs);
+
if (ctx->mgmt) {
rpc_clnt_disable (ctx->mgmt);
ctx->mgmt = NULL;
}
- __glfs_entry_fs (fs);
-
call_pool = fs->ctx->pool;
while (countdown--) {
@@ -1069,6 +1075,7 @@ pub_glfs_fini (struct glfs *fs)
if (glusterfs_ctx_destroy (ctx) != 0)
ret = -1;
+free_fs:
glfs_free_from_ctx (fs);
fail:
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 (&reg->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;
}