From e82bcc33ed2d5cd54d3f918397f31818089299ad Mon Sep 17 00:00:00 2001 From: Mohit Agrawal Date: Mon, 26 Nov 2018 14:40:00 +0530 Subject: 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 --- xlators/storage/posix/src/posix-helpers.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'xlators/storage/posix/src/posix-helpers.c') diff --git a/xlators/storage/posix/src/posix-helpers.c b/xlators/storage/posix/src/posix-helpers.c index 8f76eacd8c4..ed0516d4c4a 100644 --- a/xlators/storage/posix/src/posix-helpers.c +++ b/xlators/storage/posix/src/posix-helpers.c @@ -2116,8 +2116,6 @@ posix_spawn_health_check_thread(xlator_t *xl) goto unlock; } - /* run the thread detached, resources will be freed on exit */ - pthread_detach(priv->health_check); priv->health_check_active = _gf_true; } unlock: @@ -2220,9 +2218,9 @@ posix_spawn_disk_space_check_thread(xlator_t *xl) priv->disk_space_check_active = _gf_false; } - ret = gf_thread_create_detached(&priv->disk_space_check, - posix_disk_space_check_thread_proc, xl, - "posix_reserve"); + ret = gf_thread_create(&priv->disk_space_check, NULL, + posix_disk_space_check_thread_proc, xl, + "posix_reserve"); if (ret < 0) { priv->disk_space_check_active = _gf_false; gf_msg(xl->name, GF_LOG_ERROR, errno, P_MSG_DISK_SPACE_CHECK_FAILED, -- cgit