ntfd can sometimes receive SIG_TERM in stopping opensafd even surveillance
thread and ntfimcnd have not been started.
The patch prevents to stop surveillance thread and ntfimcnd in such case.
---
 src/ntf/ntfd/ntfs_imcnutil.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/src/ntf/ntfd/ntfs_imcnutil.c b/src/ntf/ntfd/ntfs_imcnutil.c
index cc257703b..00c2c0039 100644
--- a/src/ntf/ntfd/ntfs_imcnutil.c
+++ b/src/ntf/ntfd/ntfs_imcnutil.c
@@ -48,7 +48,7 @@ typedef struct {
        bool ntfimcn_on;
 } init_params_t;
 
-static init_params_t ipar;
+static init_params_t ipar = {0, 0, 0, false};
 pthread_mutex_t ntfimcn_mutex;
 
 /**
@@ -357,13 +357,12 @@ int stop_ntfimcn(void)
        int rc = 0;
        TRACE_ENTER();
 
+       if (ipar.ntfimcn_on == false) goto done;
        /* Kill ntfimcn */
        osaf_mutex_lock_ordie(&ntfimcn_mutex);
-       if (ipar.ntfimcn_on == true) {
-               ipar.ntfimcn_on = false;
-               TRACE("%s: Terminating osafntfimcnd process", __FUNCTION__);
-               timedwait_imcn_exit();
-       }
+       ipar.ntfimcn_on = false;
+       TRACE("%s: Terminating osafntfimcnd process", __FUNCTION__);
+       timedwait_imcn_exit();
        osaf_mutex_unlock_ordie(&ntfimcn_mutex);
 
        /* Cancel the surveillance thread */
@@ -377,7 +376,7 @@ int stop_ntfimcn(void)
        rc = pthread_mutex_destroy(&ntfimcn_mutex);
        if (rc != 0)
                osaf_abort(rc);
-
+done:
        TRACE_LEAVE();
        return rc;
 }
-- 
2.11.0


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Opensaf-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensaf-devel

Reply via email to