diff options
Diffstat (limited to 'xlators')
-rw-r--r-- | xlators/features/index/src/index.c | 24 | ||||
-rw-r--r-- | xlators/features/index/src/index.h | 1 |
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 { |