summaryrefslogtreecommitdiffstats
path: root/opengl/libagl
diff options
context:
space:
mode:
authorJamie Gennis <jgennis@google.com>2011-01-30 15:59:36 -0800
committerJamie Gennis <jgennis@google.com>2011-01-30 15:59:36 -0800
commit2076f35549c7c04035b9f626d9209e049b6c91f8 (patch)
tree91b976f2d5fc03615437843b1fc5b34bdabfa2a7 /opengl/libagl
parenta7442c95874ac05165586e00a43bee826a0eef99 (diff)
downloadframeworks_native-2076f35549c7c04035b9f626d9209e049b6c91f8.zip
frameworks_native-2076f35549c7c04035b9f626d9209e049b6c91f8.tar.gz
frameworks_native-2076f35549c7c04035b9f626d9209e049b6c91f8.tar.bz2
Fix a multithreading bug in libagl's EGL.
The bug caused libagl to return 0 from eglGetError if an EGL error value (including EGL_SUCCESS) was set on a different thread but not yet on the current thread. Bug: 3403756 Change-Id: Ifd965091d116745c2e22c121151ade9e78eb14c6
Diffstat (limited to 'opengl/libagl')
-rw-r--r--opengl/libagl/egl.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/opengl/libagl/egl.cpp b/opengl/libagl/egl.cpp
index 7ac6f92..a1cb23a 100644
--- a/opengl/libagl/egl.cpp
+++ b/opengl/libagl/egl.cpp
@@ -82,6 +82,11 @@ static GLint getError() {
if (ggl_unlikely(gEGLErrorKey == -1))
return EGL_SUCCESS;
GLint error = (GLint)pthread_getspecific(gEGLErrorKey);
+ if (error == 0) {
+ // The TLS key has been created by another thread, but the value for
+ // this thread has not been initialized.
+ return EGL_SUCCESS;
+ }
pthread_setspecific(gEGLErrorKey, (void*)EGL_SUCCESS);
return error;
}