summaryrefslogtreecommitdiffstats
path: root/xlators/features/index/src
diff options
context:
space:
mode:
authorMohit Agrawal <moagrawa@redhat.com>2017-06-06 13:44:06 +0530
committerJeff Darcy <jeff@pl.atyp.us>2017-06-07 15:42:14 +0000
commit0a07cffbf363e35e9617e5d4ef605f26ede06f05 (patch)
treeeb2d81792b42ef8260317c139dc47a2e64edd889 /xlators/features/index/src
parentbae51359b4a3a7a9c16424b43eb5ad14f0fcad53 (diff)
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 <moagrawa@redhat.com> Reviewed-on: https://review.gluster.org/17471 Smoke: Gluster Build System <jenkins@build.gluster.org> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> CentOS-regression: Gluster Build System <jenkins@build.gluster.org> Reviewed-by: Jeff Darcy <jeff@pl.atyp.us>
Diffstat (limited to 'xlators/features/index/src')
-rw-r--r--xlators/features/index/src/index.c24
-rw-r--r--xlators/features/index/src/index.h1
2 files changed, 19 insertions, 6 deletions
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 {