wined3d: Copy the module handle to a local variable in wined3d_cs_run().

Signed-off-by: Matteo Bruni <mbruni@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Matteo Bruni 2017-09-08 18:44:11 +02:00 committed by Alexandre Julliard
parent 210ce803a0
commit 6ee7f90746
1 changed files with 6 additions and 1 deletions

View File

@ -2569,11 +2569,16 @@ static DWORD WINAPI wined3d_cs_run(void *ctx)
unsigned int spin_count = 0; unsigned int spin_count = 0;
struct wined3d_cs *cs = ctx; struct wined3d_cs *cs = ctx;
enum wined3d_cs_op opcode; enum wined3d_cs_op opcode;
HMODULE wined3d_module;
unsigned int poll = 0; unsigned int poll = 0;
LONG tail; LONG tail;
TRACE("Started.\n"); TRACE("Started.\n");
/* Copy the module handle to a local variable to avoid racing with the
* thread freeing "cs" before the FreeLibraryAndExitThread() call. */
wined3d_module = cs->wined3d_module;
list_init(&cs->query_poll_list); list_init(&cs->query_poll_list);
cs->thread_id = GetCurrentThreadId(); cs->thread_id = GetCurrentThreadId();
for (;;) for (;;)
@ -2621,7 +2626,7 @@ static DWORD WINAPI wined3d_cs_run(void *ctx)
cs->queue[WINED3D_CS_QUEUE_MAP].tail = cs->queue[WINED3D_CS_QUEUE_MAP].head; cs->queue[WINED3D_CS_QUEUE_MAP].tail = cs->queue[WINED3D_CS_QUEUE_MAP].head;
cs->queue[WINED3D_CS_QUEUE_DEFAULT].tail = cs->queue[WINED3D_CS_QUEUE_DEFAULT].head; cs->queue[WINED3D_CS_QUEUE_DEFAULT].tail = cs->queue[WINED3D_CS_QUEUE_DEFAULT].head;
TRACE("Stopped.\n"); TRACE("Stopped.\n");
FreeLibraryAndExitThread(cs->wined3d_module, 0); FreeLibraryAndExitThread(wined3d_module, 0);
} }
struct wined3d_cs *wined3d_cs_create(struct wined3d_device *device) struct wined3d_cs *wined3d_cs_create(struct wined3d_device *device)