If multiple threads set/get a TSD at roughly same time for the first
time, glthread might (wronly) initialize it more than once.  This patch
solves the race by initializing context/dispatch TSDs early.

Acked-by: Ian Romanick <ian.d.roman...@intel.com>
Signed-off-by: Chia-I Wu <olva...@gmail.com>
---
 src/mesa/glapi/glapi.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/src/mesa/glapi/glapi.c b/src/mesa/glapi/glapi.c
index 30aec20..b9ab9c0 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;
    }
-- 
1.6.3.3


------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge  
This is your chance to win up to $100,000 in prizes! For a limited time, 
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize  
details at: http://p.sf.net/sfu/Challenge
_______________________________________________
Mesa3d-dev mailing list
Mesa3d-dev@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mesa3d-dev

Reply via email to