summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJosé Fonseca <jfonseca@vmware.com>2009-03-06 14:02:42 +0000
committerJosé Fonseca <jfonseca@vmware.com>2009-03-06 14:03:04 +0000
commit8bbb6b352ad7fabb2cc5ec4b82244d39495e80ac (patch)
tree2a83dab83e9278a712d8ab118ec60bfb34a918d5 /src
parentf6159ba4d5da9579de55afb01b4f460f9b8a0327 (diff)
mesa: Reads must also be done with lock held.
Otherwise two threads might think each made the refcount go zero.
Diffstat (limited to 'src')
-rw-r--r--src/mesa/main/context.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c
index 27fc26a2a4..05b19a4350 100644
--- a/src/mesa/main/context.c
+++ b/src/mesa/main/context.c
@@ -1310,6 +1310,8 @@ _mesa_create_context(const GLvisual *visual,
void
_mesa_free_context_data( GLcontext *ctx )
{
+ GLint RefCount;
+
if (!_mesa_get_current_context()){
/* No current context, but we may need one in order to delete
* texture objs, etc. So temporarily bind the context now.
@@ -1361,10 +1363,10 @@ _mesa_free_context_data( GLcontext *ctx )
/* Shared context state (display lists, textures, etc) */
_glthread_LOCK_MUTEX(ctx->Shared->Mutex);
- ctx->Shared->RefCount--;
- assert(ctx->Shared->RefCount >= 0);
+ RefCount = --ctx->Shared->RefCount;
_glthread_UNLOCK_MUTEX(ctx->Shared->Mutex);
- if (ctx->Shared->RefCount == 0) {
+ assert(RefCount >= 0);
+ if (RefCount == 0) {
/* free shared state */
free_shared_state( ctx, ctx->Shared );
}