summaryrefslogtreecommitdiff
path: root/src/gallium/drivers
diff options
context:
space:
mode:
authorEric Engestrom <eric@engestrom.ch>2017-06-15 23:53:55 +0100
committerAndres Gomez <agomez@igalia.com>2017-06-28 20:17:13 +0300
commitc2ed6935015655fa21772284a9998b918e406f04 (patch)
treeaa33609a7a53cb36e1ba6cf6f9b1eaf7c3801cde /src/gallium/drivers
parentf9c7c9f48acd85ce759262fd40d9b11277bbc2b2 (diff)
egl/display: make platform detection thread-safe
Imagine there are 2 threads that both call _eglGetNativePlatform() simultaneously: - thread 1 completes the first "if (native_platform == _EGL_INVALID_PLATFORM)" check and is preempted to do something else - thread 2 executes the whole function, does "native_platform = _EGL_NATIVE_PLATFORM" and just before returning it's preempted - thread 1 wakes up and calls _eglGetNativePlatformFromEnv() which returns _EGL_INVALID_PLATFORM because no env vars are set, updates native_platform and then gets preempted again - thread 2 wakes up and returns wrong _EGL_INVALID_PLATFORM Solve this by doing the detection in a local var and only overwriting the global one at the end, if no other thread has updated it since. This means the platform detected in the thread might not be the platform returned by the function, but this is a different issue that will need to be discussed when this becomes possible. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=101252 Signed-off-by: Eric Engestrom <eric@engestrom.ch> Reviewed-by: Grazvydas Ignotas <notasas@gmail.com> Acked-by: Emil Velikov <emil.l.velikov@gmail.com> (cherry picked from commit 311c09165881111c4a596ca7e7b4bce89b059e0f)
Diffstat (limited to 'src/gallium/drivers')
0 files changed, 0 insertions, 0 deletions