From 61e83c525ac2b414203b9efb6cc1188256534268 Mon Sep 17 00:00:00 2001 From: Vishnu Itta Date: Fri, 10 Jan 2020 23:38:24 +0530 Subject: [PATCH] fix(crash): cleanup mempool related thread while destroying volume (301) (#303) Signed-off-by: Vitta Co-authored-by: Mayank <33252549+mynktl@users.noreply.github.com> --- src/replication.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/replication.c b/src/replication.c index 55efe02e..d7c479b4 100644 --- a/src/replication.c +++ b/src/replication.c @@ -4354,19 +4354,19 @@ initialize_replication() void destroy_volume(spec_t *spec) { - int ret = 0; - void *res; + int ret = 0; + void *res; - destroy_rcommon_deadlist(spec); + pthread_cancel(spec->deadlist_cleanup_thread); + ret = pthread_join(spec->deadlist_cleanup_thread, &res); + if (ret != 0 || res != PTHREAD_CANCELED) { + REPLICA_NOTICELOG("pthread_join returned ret:%d res:%p for mempool cleanup thread\n", ret, res); + abort(); + } - pthread_cancel(spec->deadlist_cleanup_thread); - ret = pthread_join(spec->deadlist_cleanup_thread, &res); - if (ret != 0 || res != PTHREAD_CANCELED) { - REPLICA_NOTICELOG("pthread_join returned ret:%d res:%p for mempool cleanup thread\n", ret, res); - abort(); - } + destroy_rcommon_deadlist(spec); - ASSERT0(get_num_entries_from_mempool(&spec->rcommon_deadlist)); + ASSERT0(get_num_entries_from_mempool(&spec->rcommon_deadlist)); destroy_mempool(&spec->rcommon_deadlist); ASSERT(TAILQ_EMPTY(&spec->rcommon_waitq));