Fixed tdm_source to destroy when error occurs in tdm. 10/228910/1
authorJoonbum Ko <joonbum.ko@samsung.com>
Thu, 26 Mar 2020 06:57:29 +0000 (15:57 +0900)
committerJoonbum Ko <joonbum.ko@samsung.com>
Thu, 26 Mar 2020 06:57:33 +0000 (15:57 +0900)
 - If an error occurs in tdm_client_handle_events, it cannot be recovered.
  When tdm_source is no longer available due to an unexpected situation,
  twe_thread must remove it from the thread and destroy it.
 - In that case, tdm_vblank can no longer be used for surfaces and display
  that used the tdm_source.

Change-Id: I1e19e12847a03ef03e5ce7562a4e992952c4fdbb
Signed-off-by: Joonbum Ko <joonbum.ko@samsung.com>
src/tpl_wayland_egl_thread.c

index ce46b07..47ba4c1 100755 (executable)
@@ -378,7 +378,7 @@ static gboolean
 _twe_thread_tdm_source_dispatch(GSource *source, GSourceFunc cb, gpointer data)
 {
        twe_tdm_source *tdm_source = (twe_tdm_source *)source;
-       tdm_error tdm_err;
+       tdm_error tdm_err = TDM_ERROR_NONE;
        GIOCondition cond;
 
        if (!source || g_source_is_destroyed(source)) {
@@ -390,7 +390,30 @@ _twe_thread_tdm_source_dispatch(GSource *source, GSourceFunc cb, gpointer data)
 
        if (cond & G_IO_IN) {
                tdm_err = tdm_client_handle_events(tdm_source->tdm_client);
-               TPL_ASSERT(tdm_err == TDM_ERROR_NONE);
+       }
+
+       /* If an error occurs in tdm_client_handle_events, it cannot be recovered.
+        * When tdm_source is no longer available due to an unexpected situation,
+        * twe_thread must remove it from the thread and destroy it.
+        * In that case, tdm_vblank can no longer be used for surfaces and displays
+        * that used this tdm_source. */
+       if (tdm_err != TDM_ERROR_NONE) {
+               TPL_ERR("Error occured in tdm_client_handle_events. tdm_err(%d)",
+                               tdm_err);
+               TPL_WARN("tdm_source(%p) will be removed from thread.", tdm_source);
+
+               g_source_remove_unix_fd(&tdm_source->gsource, tdm_source->tag);
+               g_source_destroy(&tdm_source->gsource);
+               g_source_unref(&tdm_source->gsource);
+
+               _twe_ctx->tdm_source = NULL;
+
+               if (_twe_ctx->tdm_del_source) {
+                       _twe_del_source_fini(_twe_ctx->tdm_del_source);
+                       _twe_ctx->tdm_del_source = NULL;
+               }
+
+               return G_SOURCE_REMOVE;
        }
 
        return G_SOURCE_CONTINUE;
@@ -545,9 +568,10 @@ twe_thread_destroy(twe_thread* thread)
                if (_twe_ctx->tdm_source) {
                        g_mutex_lock(&_twe_ctx->thread_mutex);
 
-                       if (tdm_del_source)
+                       if (tdm_del_source) {
                                _twe_thread_del_source_trigger(tdm_del_source);
-                       g_cond_wait(&_twe_ctx->thread_cond, &_twe_ctx->thread_mutex);
+                               g_cond_wait(&_twe_ctx->thread_cond, &_twe_ctx->thread_mutex);
+                       }
 
                        g_mutex_unlock(&_twe_ctx->thread_mutex);
                }