Ensure fence_dpy is setup for all threads 23/127223/1 accepted/tizen/4.0/unified/20170816.012405 accepted/tizen/4.0/unified/20170816.015300 accepted/tizen/4.0/unified/20170828.224236 accepted/tizen/unified/20170428.032549 submit/tizen/20170427.063328 submit/tizen_4.0/20170811.094300 submit/tizen_4.0/20170814.115522 submit/tizen_4.0/20170828.110001 submit/tizen_4.0_unified/20170814.115522 tizen_4.0.m1_release
authorVasiliy Ulyanov <v.ulyanov@samsung.com>
Wed, 26 Apr 2017 11:59:27 +0000 (14:59 +0300)
committerVasiliy Ulyanov <v.ulyanov@samsung.com>
Wed, 26 Apr 2017 12:14:40 +0000 (15:14 +0300)
This is needed in order to be able to create fences in transport layer
and avoid race conditions when invoking yagl_host_* routines with return
values. Previously fence_dpy was assigned only in eglGetDisplay. Though
the app may make EGL calls from auxiliary threads which will have
fence_dpy uninitialized.

Change-Id: Ibe66030cb4a30d189750d1ab233164cfea60b339
Signed-off-by: Vasiliy Ulyanov <v.ulyanov@samsung.com>
EGL/yagl_display.c

index 60b8d023bd825b4abacbec670c0cfdb0e86b9cfa..1433c8a4f72d548a4079c3861f67e0e374aa6dcf 100644 (file)
@@ -131,6 +131,20 @@ struct yagl_display *yagl_display_get(EGLDisplay handle)
         if (dpy->host_dpy == host_dpy) {
             pthread_mutex_unlock(&g_displays_mutex);
 
+            /*
+             * We need to make sure fence_dpy is setup properly for current
+             * thread state. Otherwise we may not be able to create fences in
+             * transport layer and eventually will face a race condition between
+             * host and target.
+             *
+             * E.g. the app may initialize all EGL stuff (i.e. get display,
+             * choose config, etc.) and save it to some global state var. If
+             * then it tries to create new context in some other thread,
+             * fence_dpy will be NULL and as a result we may not get proper
+             * values returned from the host.
+             */
+            yagl_set_fence_display(dpy);
+
             return dpy;
         }
     }