From e93bd7a3bf2e8a419a0aeeaec009f0bab5cfaf10 Mon Sep 17 00:00:00 2001 From: Geoffrey McRae Date: Fri, 30 Aug 2019 11:50:43 +1000 Subject: [PATCH] [client] fix shutdown race condition with the frame thread --- VERSION | 2 +- client/src/main.c | 13 +++++++------ client/src/main.h | 4 +++- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/VERSION b/VERSION index 3a1c7647..639a64e6 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -fetch-2-g69522495de+1 \ No newline at end of file +fetch-4-gf7d2295dab+1 \ No newline at end of file diff --git a/client/src/main.c b/client/src/main.c index 62470a60..eee3ac04 100644 --- a/client/src/main.c +++ b/client/src/main.c @@ -155,7 +155,12 @@ static int renderThread(void * unused) } state.running = false; - SDL_WaitThread(t_cursor, NULL); + + if (t_cursor) + SDL_WaitThread(t_cursor, NULL); + + if (state.t_frame) + SDL_WaitThread(state.t_frame, NULL); state.lgr->deinitialize(state.lgrData); state.lgr = NULL; @@ -1204,7 +1209,6 @@ int run() } SDL_Thread *t_spice = NULL; - SDL_Thread *t_frame = NULL; SDL_Thread *t_render = NULL; while(1) @@ -1284,7 +1288,7 @@ int run() break; } - if (!(t_frame = SDL_CreateThread(frameThread, "frameThread", NULL))) + if (!(state.t_frame = SDL_CreateThread(frameThread, "frameThread", NULL))) { DEBUG_ERROR("frame create thread failed"); break; @@ -1326,9 +1330,6 @@ int run() if (t_render) SDL_WaitThread(t_render, NULL); - if (t_frame) - SDL_WaitThread(t_frame, NULL); - // if spice is still connected send key up events for any pressed keys if (params.useSpiceInput && spice_ready()) { diff --git a/client/src/main.h b/client/src/main.h index 806ea72c..276c9d41 100644 --- a/client/src/main.h +++ b/client/src/main.h @@ -49,6 +49,8 @@ struct AppState void * lgrData; bool lgrResize; + SDL_Thread * t_frame; + const LG_Clipboard * lgc; SpiceDataType cbType; struct ll * cbRequestList; @@ -130,4 +132,4 @@ struct KeybindHandle // forwards extern struct AppState state; -extern struct AppParams params; +extern struct AppParams params; \ No newline at end of file