From ae2aa286af67f7990486ca6476e73f677c58872b Mon Sep 17 00:00:00 2001 From: Jamie Gennis Date: Sun, 30 Jan 2011 15:59:36 -0800 Subject: 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 --- opengl/libagl/egl.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'opengl/libagl/egl.cpp') diff --git a/opengl/libagl/egl.cpp b/opengl/libagl/egl.cpp index 7ac6f9277638..a1cb23a250b9 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; } -- cgit v1.2.3-59-g8ed1b