tpl_wayland_egl_thread: Modified del_source related thread_cond. 71/205871/1
authorJoonbum Ko <joonbum.ko@samsung.com>
Fri, 10 May 2019 04:10:11 +0000 (13:10 +0900)
committerJoonbum Ko <joonbum.ko@samsung.com>
Fri, 10 May 2019 04:10:11 +0000 (13:10 +0900)
Change-Id: I2547293e6849c2fb6322d0351f437ed5580a6e73
Signed-off-by: Joonbum Ko <joonbum.ko@samsung.com>
src/tpl_wayland_egl_thread.c

index 8e65783..767dba7 100644 (file)
@@ -240,8 +240,12 @@ _twe_thread_del_source_dispatch(GSource *source, GSourceFunc cb, gpointer data)
        twe_del_source *del_source = (twe_del_source *)source;
        GIOCondition cond;
 
+       g_mutex_lock(&_twe_ctx->thread_mutex);
+
        if (g_source_is_destroyed(source)) {
                TPL_ERR("del_source(%p) already destroyed.", source);
+               g_cond_signal(&_twe_ctx->thread_cond);
+               g_mutex_unlock(&_twe_ctx->thread_mutex);
                return G_SOURCE_REMOVE;
        }
 
@@ -261,9 +265,14 @@ _twe_thread_del_source_dispatch(GSource *source, GSourceFunc cb, gpointer data)
        } else {
                TPL_ERR("eventfd(%d) cannot wake up with other condition. cond(%d)",
                                del_source->event_fd, cond);
+               g_cond_signal(&_twe_ctx->thread_cond);
+               g_mutex_unlock(&_twe_ctx->thread_mutex);
                TPL_ASSERT((cond & G_IO_IN));
        }
 
+       g_cond_signal(&_twe_ctx->thread_cond);
+       g_mutex_unlock(&_twe_ctx->thread_mutex);
+
        return G_SOURCE_CONTINUE;
 }
 
@@ -448,12 +457,8 @@ _twe_thread_tdm_source_destroy(void *source)
 {
        twe_tdm_source *tdm_source = (twe_tdm_source *)source;
 
-       g_mutex_lock(&_twe_ctx->thread_mutex);
-
        if (!tdm_source || g_source_is_destroyed(&tdm_source->gsource)) {
                TPL_ERR("TDM source(%p) already destroyed.", tdm_source);
-               g_cond_signal(&_twe_ctx->thread_cond);
-               g_mutex_unlock(&_twe_ctx->thread_mutex);
                return;
        }
 
@@ -462,9 +467,6 @@ _twe_thread_tdm_source_destroy(void *source)
        g_source_remove_unix_fd(&tdm_source->gsource, tdm_source->tag);
        g_source_destroy(&tdm_source->gsource);
        g_source_unref(&tdm_source->gsource);
-
-       g_cond_signal(&_twe_ctx->thread_cond);
-       g_mutex_unlock(&_twe_ctx->thread_mutex);
 }
 
 twe_thread*
@@ -888,7 +890,6 @@ _twe_thread_wl_disp_source_destroy(void *source)
                return;
        }
 
-       g_mutex_lock(&_twe_ctx->thread_mutex);
        g_mutex_lock(&disp_source->wl_event_mutex);
 
        /* If disp_source is in prepared state, cancel it */
@@ -913,9 +914,6 @@ _twe_thread_wl_disp_source_destroy(void *source)
        g_source_remove_poll(&disp_source->gsource, &disp_source->gfd);
        g_source_destroy(&disp_source->gsource);
        g_source_unref(&disp_source->gsource);
-
-       g_cond_signal(&_twe_ctx->thread_cond);
-       g_mutex_unlock(&_twe_ctx->thread_mutex);
 }
 
 twe_display_h
@@ -2269,8 +2267,6 @@ _twe_thread_wl_surf_source_destroy(void *source)
                return;
        }
 
-       g_mutex_lock(&_twe_ctx->thread_mutex);
-
        g_mutex_lock(&disp_source->wl_event_mutex);
 
        g_mutex_lock(&surf_source->surf_mutex);
@@ -2356,9 +2352,6 @@ _twe_thread_wl_surf_source_destroy(void *source)
        g_source_remove_unix_fd(&surf_source->gsource, surf_source->tag);
        g_source_destroy(&surf_source->gsource);
        g_source_unref(&surf_source->gsource);
-
-       g_cond_signal(&_twe_ctx->thread_cond);
-       g_mutex_unlock(&_twe_ctx->thread_mutex);
 }
 
 static gpointer