mesa/glthread: don't set a dispatch table if we aren't the owner

Fix crashes when glxMakeCurrent is called.

Signed-off-by: Gregory Hainaut <gregory.hainaut@gmail.com>
Signed-off-by: Marek Olšák <marek.olsak@amd.com>
Acked-by: Timothy Arceri <tarceri@itsqueeze.com>
Tested-by: Dieter Nützel <Dieter@nuetzel-hh.de>
Tested-by: Mike Lothian <mike@fireburn.co.uk>
This commit is contained in:
Gregory Hainaut 2017-02-13 19:14:28 +01:00 committed by Timothy Arceri
parent 012bfebc07
commit 70e715eea6

View file

@ -173,9 +173,16 @@ _mesa_glthread_destroy(struct gl_context *ctx)
free(glthread);
ctx->GLThread = NULL;
/* Remove ourselves from the dispatch table. */
ctx->CurrentClientDispatch = ctx->CurrentServerDispatch;
_glapi_set_dispatch(ctx->CurrentClientDispatch);
/* Remove ourselves from the dispatch table except if another ctx/thread
* already installed a new dispatch table.
*
* Typically glxMakeCurrent will bind a new context (install new table) then
* old context might be deleted.
*/
if (_glapi_get_dispatch() == ctx->MarshalExec) {
ctx->CurrentClientDispatch = ctx->CurrentServerDispatch;
_glapi_set_dispatch(ctx->CurrentClientDispatch);
}
}
void