Move position of cond_polling_init() 25/76925/2
authorsung.goo.kim <sung.goo.kim@samsung.com>
Tue, 28 Jun 2016 04:42:59 +0000 (13:42 +0900)
committersung.goo.kim <sung.goo.kim@samsung.com>
Tue, 28 Jun 2016 05:06:59 +0000 (14:06 +0900)
Change-Id: Id56b36a1fc916d5c43d3f6ff1b57e025b8ee95aa

lib/icl-ioty-ocprocess.c
lib/icl-ioty.c

index 9b60d8d6af1fa2a6d229c45c404b3a58675d58a2..3d2d99b3c678e16b02d2c215b6ed4edf0d9b43f4 100644 (file)
@@ -105,10 +105,6 @@ void* icl_ioty_ocprocess_thread(void *data)
        if (0 != ret)
                ERR("prctl(PR_SET_NAME) Fail(%d)", ret);
 
-       ret = ic_utils_cond_polling_init();
-       if (IOTCON_ERROR_NONE != ret)
-               ERR("ic_utils_cond_polling_init() Fail(%d)", ret);
-
        ic_utils_mutex_lock(IC_UTILS_MUTEX_POLLING);
        while (icl_ioty_alive) {
                ic_utils_mutex_lock(IC_UTILS_MUTEX_IOTY);
@@ -124,8 +120,6 @@ void* icl_ioty_ocprocess_thread(void *data)
        }
        ic_utils_mutex_unlock(IC_UTILS_MUTEX_POLLING);
 
-       ic_utils_cond_polling_destroy();
-
        return NULL;
 }
 
index 1c911e11b6f55aacd4c5fb471e67857ccebce9ac..8bbfb37e537c5da2111732d8bb7f503e97bbc909 100644 (file)
@@ -63,10 +63,15 @@ void icl_ioty_deinit(pthread_t thread)
 
        icl_ioty_ocprocess_stop();
        ic_utils_cond_signal(IC_UTILS_COND_POLLING);
+
        ret = pthread_join(thread, NULL);
        if (0 != ret)
                ERR("pthread_join() Fail(%d)", ret);
 
+       INFO("pthread_join finished");
+
+       ic_utils_cond_polling_destroy();
+
        result = OCStop();
        if (OC_STACK_OK != result)
                ERR("OCStop() Fail(%d)", result);
@@ -167,6 +172,10 @@ int icl_ioty_init(pthread_t *out_thread)
                ERR("pthread_attr_setstacksize() Fail(%d)", ret);
 #endif
 
+       ret = ic_utils_cond_polling_init();
+       if (IOTCON_ERROR_NONE != ret)
+               ERR("ic_utils_cond_polling_init() Fail(%d)", ret);
+
        ret = pthread_create(out_thread, &attr, icl_ioty_ocprocess_thread, NULL);
        if (0 != ret) {
                ERR("pthread_create() Fail(%d)", ret);