summaryrefslogtreecommitdiff
path: root/src/mesa/glapi
diff options
context:
space:
mode:
authorChia-I Wu <olvaffe@gmail.com>2009-07-10 17:35:11 +0800
committerBrian Paul <brianp@vmware.com>2009-08-24 11:45:57 -0600
commitfc2feea685d86c520fb01199caa5a46eae20c7aa (patch)
treedd8619d17770db2a92121216394f474a8cea0e43 /src/mesa/glapi
parent99939982ec76cb1fee84da9027375c55888dca20 (diff)
glapi: Fix a race in accessing context/dispatch TSD.
If multiple threads set/get a TSD at roughly same time for the first time, glthread might (wrongly) initialize it more than once. This patch solves the race by initializing context/dispatch TSDs early. Acked-by: Ian Romanick <ian.d.romanick@intel.com> Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Diffstat (limited to 'src/mesa/glapi')
-rw-r--r--src/mesa/glapi/glapi.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/mesa/glapi/glapi.c b/src/mesa/glapi/glapi.c
index 30aec209e7..b9ab9c07be 100644
--- a/src/mesa/glapi/glapi.c
+++ b/src/mesa/glapi/glapi.c
@@ -240,6 +240,10 @@ _glapi_check_multithread(void)
_glthread_LOCK_MUTEX(ThreadCheckMutex);
if (firstCall) {
+ /* initialize TSDs */
+ (void) _glthread_GetTSD(&ContextTSD);
+ (void) _glthread_GetTSD(&_gl_DispatchTSD);
+
knownID = _glthread_GetID();
firstCall = GL_FALSE;
}