summaryrefslogtreecommitdiffstats
path: root/xlators/storage/posix/src/posix-common.c
diff options
context:
space:
mode:
authorMohit Agrawal <moagrawal@redhat.com>2018-11-26 14:40:00 +0530
committerAmar Tumballi <amarts@redhat.com>2018-12-11 04:01:40 +0000
commite82bcc33ed2d5cd54d3f918397f31818089299ad (patch)
treef392bbd8df4979f13eebac86df6177e88682ec13 /xlators/storage/posix/src/posix-common.c
parent2b7b6ff28fa92335613d0b5715acd552cfcfd759 (diff)
posix: posix_health_check_thread_proc crash due to priv is NULL
Problem: posix_fini sends a cancellation request to health_check thread and cleanup priv without ensuring health_check thread is running Solution: Make health_check && disk_space thread joinable and call gf_thread_cleanup_xint to wait unless thread is not finished Change-Id: I4d37b08138766881dab0922a47ed68a2c3411f13 fixes: bz#1636570 Signed-off-by: Mohit Agrawal <moagrawal@redhat.com>
Diffstat (limited to 'xlators/storage/posix/src/posix-common.c')
-rw-r--r--xlators/storage/posix/src/posix-common.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/xlators/storage/posix/src/posix-common.c b/xlators/storage/posix/src/posix-common.c
index fd7c9fe..111542e 100644
--- a/xlators/storage/posix/src/posix-common.c
+++ b/xlators/storage/posix/src/posix-common.c
@@ -1071,18 +1071,25 @@ void
posix_fini(xlator_t *this)
{
struct posix_private *priv = this->private;
+ gf_boolean_t health_check = _gf_false;
+
if (!priv)
return;
LOCK(&priv->lock);
- if (priv->health_check_active) {
+ {
+ health_check = priv->health_check_active;
priv->health_check_active = _gf_false;
- pthread_cancel(priv->health_check);
- priv->health_check = 0;
}
UNLOCK(&priv->lock);
+
+ if (health_check) {
+ (void)gf_thread_cleanup_xint(priv->health_check);
+ priv->health_check = 0;
+ }
+
if (priv->disk_space_check) {
priv->disk_space_check_active = _gf_false;
- pthread_cancel(priv->disk_space_check);
+ (void)gf_thread_cleanup_xint(priv->disk_space_check);
priv->disk_space_check = 0;
}
if (priv->janitor) {