Wait for terminating sub thread when vc client is deinitialized 23/320323/1 accepted/tizen/unified/20241114.092409
authorurmain <wn.jang@samsung.com>
Wed, 13 Nov 2024 02:38:23 +0000 (11:38 +0900)
committerTizen AI <ai.tzn.sec@samsung.com>
Wed, 13 Nov 2024 06:55:06 +0000 (15:55 +0900)
Casuse: The crash was happened when application had called vc_deinitialize()
function because g_prepare_thread had been alived.

Change-Id: I7e171f01bff1152097918b70d1564b25923e20b7
Solution: Wait for terminating g_prepare thread after cancelling.

client/vc.c

index 39bd7aa78b5690b7cca3b29a1c5b7c05d69f7235..75300694be8067453d24b5acff667335fed2149a 100644 (file)
@@ -489,8 +489,12 @@ int vc_deinitialize(void)
                /* no break. need to next step*/
        case VC_STATE_INITIALIZED:
                pthread_mutex_lock(&g_prepare_thread_mutex);
-               if (NULL != g_prepare_thread) {
+               if (NULL != g_prepare_thread && EINA_FALSE == ecore_thread_check(g_prepare_thread)) {
+                       SLOG(LOG_INFO, TAG_VCC, "[INFO] Cancel prepare thread");
                        ecore_thread_cancel(g_prepare_thread);
+
+                       ecore_thread_wait(g_prepare_thread, 1.0); // wait g_prepare_thread is terminated.
+                       g_prepare_thread = NULL;
                }
                pthread_mutex_unlock(&g_prepare_thread_mutex);