diff options
author | José Fonseca <jfonseca@vmware.com> | 2009-05-01 18:52:54 +0100 |
---|---|---|
committer | Keith Whitwell <keithw@vmware.com> | 2009-05-08 10:04:13 +0100 |
commit | b25168c34c60760a33ca9e8336ac76cf1219f143 (patch) | |
tree | 435a7e244891e8e236ea60e755afb6f980403e29 | |
parent | 25a4156a8b0bc59f7d3f077526b7e3e350b072ea (diff) |
mesa: Make _mesa_share_state thread safe.
-rw-r--r-- | src/mesa/main/context.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c index 1a290f251ad..ddbc631e674 100644 --- a/src/mesa/main/context.c +++ b/src/mesa/main/context.c @@ -1394,14 +1394,21 @@ _mesa_share_state(GLcontext *ctx, GLcontext *ctxToShare) { if (ctx && ctxToShare && ctx->Shared && ctxToShare->Shared) { struct gl_shared_state *oldSharedState = ctx->Shared; + GLint RefCount; ctx->Shared = ctxToShare->Shared; + + _glthread_LOCK_MUTEX(ctx->Shared->Mutex); ctx->Shared->RefCount++; + _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex); update_default_objects(ctx); - oldSharedState->RefCount--; - if (oldSharedState->RefCount == 0) { + _glthread_LOCK_MUTEX(oldSharedState->Mutex); + RefCount = --oldSharedState->RefCount; + _glthread_UNLOCK_MUTEX(oldSharedState->Mutex); + + if (RefCount == 0) { _mesa_free_shared_state(ctx, oldSharedState); } |