From: Chia-I Wu Date: Fri, 10 Jul 2009 09:35:11 +0000 (+0800) Subject: glapi: Fix a race in accessing context/dispatch TSD. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=fc2feea685d86c520fb01199caa5a46eae20c7aa;p=mesa.git 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 Signed-off-by: Chia-I Wu --- diff --git a/src/mesa/glapi/glapi.c b/src/mesa/glapi/glapi.c index 30aec209e7d..b9ab9c07be1 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; }