mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-02-23 14:00:30 +01:00
mesa: Reads must also be done with lock held.
Otherwise two threads might think each made the refcount go zero.
(cherry picked from master, commit 8bbb6b352a)
This commit is contained in:
parent
a22088b7d5
commit
6801240205
1 changed files with 5 additions and 3 deletions
|
|
@ -1293,6 +1293,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.
|
||||
|
|
@ -1342,10 +1344,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 );
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue