Don't try freeing the context in ReleaseThreadCtx

Unfortunately on certain systems, the TLS callback is called in a restricted
context, and isn't allowed to access certain messaging sub-systems. Such sub-
systems may be used if the thread's context is freed, in turn freeing the
device, which it tries to close.

Ideally, the app shouldn't have tried to destroy a context while it was still
current on a thread, or even leave a context current on a thread that's being
destroyed,. So for now, release the context ref and print an ERR that it might
be leaked.
This commit is contained in:
Chris Robinson
2016-07-29 08:02:02 -07:00
parent 5e11a738c6
commit 96e83f95ee
+6 -6
View File
@@ -2376,23 +2376,23 @@ static void ReleaseContext(ALCcontext *context, ALCdevice *device)
void ALCcontext_IncRef(ALCcontext *context)
{
uint ref;
ref = IncrementRef(&context->ref);
uint ref = IncrementRef(&context->ref);
TRACEREF("%p increasing refcount to %u\n", context, ref);
}
void ALCcontext_DecRef(ALCcontext *context)
{
uint ref;
ref = DecrementRef(&context->ref);
uint ref = DecrementRef(&context->ref);
TRACEREF("%p decreasing refcount to %u\n", context, ref);
if(ref == 0) FreeContext(context);
}
static void ReleaseThreadCtx(void *ptr)
{
WARN("%p current for thread being destroyed\n", ptr);
ALCcontext_DecRef(ptr);
ALCcontext *context = ptr;
uint ref = DecrementRef(&context->ref);
TRACEREF("%p decreasing refcount to %u\n", context, ref);
ERR("Context %p current for thread being destroyed, possible leak!\n", context);
}
/* VerifyContext