From 0a07cffbf363e35e9617e5d4ef605f26ede06f05 Mon Sep 17 00:00:00 2001 From: Mohit Agrawal Date: Tue, 6 Jun 2017 13:44:06 +0530 Subject: glusterfsd: Sometime brick process is crashed after enable brick mux Problem: glusterfsd is getting Segfault while running bug-1432542-mpx-restart-crash.t in a loop in while brick mux is enabled. Solution: Change the index_worker code as well as notify code in index.c to cleanup index_worker thread appropriately. BUG: 1459402 Change-Id: Id036664dc34309dd3f6e54746fc2724182cb074f Signed-off-by: Mohit Agrawal Reviewed-on: https://review.gluster.org/17471 Smoke: Gluster Build System NetBSD-regression: NetBSD Build System CentOS-regression: Gluster Build System Reviewed-by: Jeff Darcy --- xlators/features/index/src/index.c | 24 ++++++++++++++++++------ xlators/features/index/src/index.h | 1 + 2 files changed, 19 insertions(+), 6 deletions(-) (limited to 'xlators/features') diff --git a/xlators/features/index/src/index.c b/xlators/features/index/src/index.c index f0462dcb7eb..59af418fca2 100644 --- a/xlators/features/index/src/index.c +++ b/xlators/features/index/src/index.c @@ -199,6 +199,8 @@ index_worker (void *data) index_priv_t *priv = NULL; xlator_t *this = NULL; call_stub_t *stub = NULL; + gf_boolean_t bye = _gf_false; + THIS = data; this = data; @@ -208,16 +210,27 @@ index_worker (void *data) pthread_mutex_lock (&priv->mutex); { while (list_empty (&priv->callstubs)) { + if (priv->down) { + bye = _gf_true;/*Avoid wait*/ + break; + } (void) pthread_cond_wait (&priv->cond, &priv->mutex); + if (priv->down) { + bye = _gf_true; + break; + } } - - stub = __index_dequeue (&priv->callstubs); + if (!bye) + stub = __index_dequeue (&priv->callstubs); } pthread_mutex_unlock (&priv->mutex); if (stub) /* guard against spurious wakeups */ call_resume (stub); + stub = NULL; + if (bye) + break; } return NULL; @@ -2380,6 +2393,7 @@ init (xlator_t *this) /*init indices files counts*/ count = index_fetch_link_count (this, XATTROP); index_set_link_count (priv, count, XATTROP); + priv->down = _gf_false; ret = gf_thread_create (&priv->thread, &w_attr, index_worker, this); if (ret) { @@ -2505,10 +2519,8 @@ notify (xlator_t *this, int event, void *data, ...) switch (event) { case GF_EVENT_CLEANUP: - if (priv->thread) { - (void) gf_thread_cleanup_xint (priv->thread); - priv->thread = 0; - } + priv->down = _gf_true; + pthread_cond_broadcast (&priv->cond); break; } diff --git a/xlators/features/index/src/index.h b/xlators/features/index/src/index.h index f622ceced5b..ae9091d69c9 100644 --- a/xlators/features/index/src/index.h +++ b/xlators/features/index/src/index.h @@ -61,6 +61,7 @@ typedef struct index_priv { dict_t *complete_watchlist; int64_t pending_count; pthread_t thread; + gf_boolean_t down; } index_priv_t; typedef struct index_local { -- cgit