Add missing Lock 63/305263/4
authorjphnix <jphnix99@gmail.com>
Tue, 30 Jan 2024 10:33:55 +0000 (10:33 +0000)
committerJinbong Lee <jinbong.lee@samsung.com>
Wed, 31 Jan 2024 09:01:22 +0000 (09:01 +0000)
 - gthread->loop is held with thread_mutex.
 - But it doesn't hold thread_mutex in tpl_gthread_add_idle

Change-Id: Ibaddbcf7e4d4b9ec661ee69c0a95dbc517970ea2

src/tpl_utils_gthread.c

index 54cd2b6..466baef 100644 (file)
@@ -627,7 +627,10 @@ tpl_gthread_add_idle(tpl_gthread *gthread, tpl_gsource_func idle_cb, void *data)
        g_source_set_callback(idle_source,
                                                  idle_cb, (gpointer)data,
                                                  NULL);
+
+       g_mutex_lock(&gthread->thread_mutex);
        g_source_attach(idle_source, g_main_loop_get_context(gthread->loop));
+       g_mutex_unlock(&gthread->thread_mutex);
        g_source_unref(idle_source);
 
        return TPL_ERROR_NONE;