Mesa (master): mesa: Make _mesa_share_state thread safe.
Keith Whitwell
keithw at kemper.freedesktop.org
Fri May 8 09:04:20 UTC 2009
Module: Mesa
Branch: master
Commit: b25168c34c60760a33ca9e8336ac76cf1219f143
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=b25168c34c60760a33ca9e8336ac76cf1219f143
Author: José Fonseca <jfonseca at vmware.com>
Date: Fri May 1 18:52:54 2009 +0100
mesa: Make _mesa_share_state thread safe.
---
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 1a290f2..ddbc631 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);
}
More information about the mesa-commit
mailing list