diff options
author | José Fonseca <jfonseca@vmware.com> | 2009-05-01 18:52:54 +0100 |
---|---|---|
committer | Keith Whitwell <keithw@vmware.com> | 2009-05-08 14:57:29 +0100 |
commit | d88faf91e9fe222636b33540298ee64bc6f4416c (patch) | |
tree | 274400bdd1948c9629d2baed2ec1c3fb5530b03e /src/mesa/main | |
parent | 4d28fcfeaa6be438f6739fddcb0661ae97a68919 (diff) |
mesa: Make _mesa_share_state thread safe.
Diffstat (limited to 'src/mesa/main')
-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 d780f91f04..60c48289e4 100644 --- a/src/mesa/main/context.c +++ b/src/mesa/main/context.c @@ -1397,14 +1397,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); } |