aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLingfeng Yang <lfy@google.com>2018-09-30 12:39:30 -0700
committerLingfeng Yang <lfy@google.com>2018-09-30 13:31:19 -0700
commitb3430543a8ae15c8629bf7743b1c89c481eb85ae (patch)
tree3fae721e2c462a0efcd60a4adabbcc1003fa4982
parent5b63a9d1b7bfabfd5e49a64f579e2542eda6c161 (diff)
downloaddevice_generic_goldfish-opengl-b3430543a8ae15c8629bf7743b1c89c481eb85ae.tar.gz
device_generic_goldfish-opengl-b3430543a8ae15c8629bf7743b1c89c481eb85ae.tar.bz2
device_generic_goldfish-opengl-b3430543a8ae15c8629bf7743b1c89c481eb85ae.zip
Aggressively exit HostConnection on eglReleaseThread
bug: 116981035 - Needed for proper thread cleanup on host side goldfish-opengl tests Change-Id: If77e3730d23f90ce1e93b90e2c7ff73a379d8c02
-rw-r--r--system/OpenglSystemCommon/ThreadInfo.cpp5
-rw-r--r--system/egl/egl.cpp7
2 files changed, 10 insertions, 2 deletions
diff --git a/system/OpenglSystemCommon/ThreadInfo.cpp b/system/OpenglSystemCommon/ThreadInfo.cpp
index 32bb54ec..31a8fe99 100644
--- a/system/OpenglSystemCommon/ThreadInfo.cpp
+++ b/system/OpenglSystemCommon/ThreadInfo.cpp
@@ -29,7 +29,10 @@ static bool (*sTlsDestructorCallback)(void*) = sDefaultTlsDestructorCallback;
static void tlsDestruct(void *ptr)
{
sTlsDestructorCallback(ptr);
- if (ptr) {
+ if (ptr
+#ifdef __ANDROID__
+ && ((void **)__get_tls())[TLS_SLOT_OPENGL]) {
+#endif
EGLThreadInfo *ti = (EGLThreadInfo *)ptr;
delete ti->hostConn;
delete ti;
diff --git a/system/egl/egl.cpp b/system/egl/egl.cpp
index c5fc04a2..5b645c0b 100644
--- a/system/egl/egl.cpp
+++ b/system/egl/egl.cpp
@@ -1288,7 +1288,10 @@ static EGLBoolean s_eglReleaseThreadImpl(EGLThreadInfo* tInfo) {
tInfo->eglError = EGL_SUCCESS;
EGLContext_t* context = tInfo->currentContext;
- if (!context || !s_display.isContext(context)) return EGL_TRUE;
+ if (!context || !s_display.isContext(context)) {
+ HostConnection::exit();
+ return EGL_TRUE;
+ }
// The following code is doing pretty much the same thing as
// eglMakeCurrent(&s_display, EGL_NO_CONTEXT, EGL_NO_SURFACE, EGL_NO_SURFACE)
@@ -1310,6 +1313,8 @@ static EGLBoolean s_eglReleaseThreadImpl(EGLThreadInfo* tInfo) {
}
tInfo->currentContext = 0;
+ HostConnection::exit();
+
return EGL_TRUE;
}