OSDN Git Service

glapi: Fix a possible race in getting current context/dispatch.
authorChia-I Wu <olvaffe@gmail.com>
Fri, 10 Jul 2009 07:28:55 +0000 (15:28 +0800)
committerBrian Paul <brianp@vmware.com>
Mon, 24 Aug 2009 17:46:15 +0000 (11:46 -0600)
commit17090cf3efb0db8fa01b502a9c0df27cbd1a67da
tree60b29d7e22a9326b8747dbb4a3d5fa495b9b758c
parent3076d1617db67d49ff773096123c1fa47af58272
glapi: Fix a possible race in getting current context/dispatch.

There is a possbile race that _glapi_Context is reset by another thread
after it is tested in GET_CURRENT_CONTEXT but before it is returned.  We
definitely do not want a lock here to solve the race.  To have correct
results even under a race, no other threads should reset _glapi_Context
(or _glapi_Dispatch).

This patch adds a new global variable _glapi_SingleThreaded.  Since
_glapi_Context or _glapi_Dispatch are no longer reset,
_glapi_SingleThreaded is tested instead, before accessing them.

DRI drivers compiled with this patch applied will not work with existing
libGL.so because of the missing new symbol.  If this turns out to be a
real problem, this patch should be reverted.

Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
src/mesa/glapi/glapi.c
src/mesa/glapi/glapi.h
src/mesa/glapi/glthread.h