summaryrefslogtreecommitdiffstats
path: root/libglusterfs/src
diff options
context:
space:
mode:
authorJeff Darcy <jdarcy@fb.com>2017-07-07 07:49:45 -0700
committerJeff Darcy <jeff@pl.atyp.us>2017-07-09 03:57:26 +0000
commit028d82b8a2434cb6d5ad707500f6dea2125ea2fa (patch)
tree51ed3680ab4dd849e65ac646b7bf698f23d6bc49 /libglusterfs/src
parent0ae38df6403942a2438404d46a6e05b503db3485 (diff)
gfapi+libglusterfs: fix mem_pools_fini without mem_pools_init case
The change consists of two parts: make sure it doesn't happen (in glfs.c), and make it harmless if it does (in mem-pool.c). Change-Id: Icb7dda7a45dd3d1ade2ee3991bb6a22c8ec88424 BUG: 1468863 Signed-off-by: Jeff Darcy <jdarcy@fb.com> Reviewed-on: https://review.gluster.org/17728 Tested-by: Jeff Darcy <jeff@pl.atyp.us> CentOS-regression: Gluster Build System <jenkins@build.gluster.org> Smoke: Gluster Build System <jenkins@build.gluster.org> Reviewed-by: Jeff Darcy <jeff@pl.atyp.us>
Diffstat (limited to 'libglusterfs/src')
-rw-r--r--libglusterfs/src/mem-pool.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/libglusterfs/src/mem-pool.c b/libglusterfs/src/mem-pool.c
index e116437583e..456eb68c060 100644
--- a/libglusterfs/src/mem-pool.c
+++ b/libglusterfs/src/mem-pool.c
@@ -560,10 +560,24 @@ void
mem_pools_fini (void)
{
pthread_mutex_lock (&init_mutex);
- GF_ASSERT (init_count > 0);
- if ((--init_count) == 0) {
+ switch (init_count) {
+ case 0:
+ /*
+ * If init_count is already zero (as e.g. if somebody called
+ * this before mem_pools_init) then the sweeper was probably
+ * never even started so we don't need to stop it. Even if
+ * there's some crazy circumstance where there is a sweeper but
+ * init_count is still zero, that just means we'll leave it
+ * running. Not perfect, but far better than any known
+ * alternative.
+ */
+ break;
+ case 1:
(void) pthread_cancel (sweeper_tid);
(void) pthread_join (sweeper_tid, NULL);
+ /* Fall through. */
+ default:
+ --init_count;
}
pthread_mutex_unlock (&init_mutex);
}