[client] fix shutdown race condition with the frame thread

This commit is contained in:
Geoffrey McRae 2019-08-30 11:50:43 +10:00
parent da94075e7b
commit e93bd7a3bf
3 changed files with 11 additions and 8 deletions

View File

@ -1 +1 @@
fetch-2-g69522495de+1 fetch-4-gf7d2295dab+1

View File

@ -155,8 +155,13 @@ static int renderThread(void * unused)
} }
state.running = false; state.running = false;
if (t_cursor)
SDL_WaitThread(t_cursor, NULL); SDL_WaitThread(t_cursor, NULL);
if (state.t_frame)
SDL_WaitThread(state.t_frame, NULL);
state.lgr->deinitialize(state.lgrData); state.lgr->deinitialize(state.lgrData);
state.lgr = NULL; state.lgr = NULL;
return 0; return 0;
@ -1204,7 +1209,6 @@ int run()
} }
SDL_Thread *t_spice = NULL; SDL_Thread *t_spice = NULL;
SDL_Thread *t_frame = NULL;
SDL_Thread *t_render = NULL; SDL_Thread *t_render = NULL;
while(1) while(1)
@ -1284,7 +1288,7 @@ int run()
break; break;
} }
if (!(t_frame = SDL_CreateThread(frameThread, "frameThread", NULL))) if (!(state.t_frame = SDL_CreateThread(frameThread, "frameThread", NULL)))
{ {
DEBUG_ERROR("frame create thread failed"); DEBUG_ERROR("frame create thread failed");
break; break;
@ -1326,9 +1330,6 @@ int run()
if (t_render) if (t_render)
SDL_WaitThread(t_render, NULL); 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 spice is still connected send key up events for any pressed keys
if (params.useSpiceInput && spice_ready()) if (params.useSpiceInput && spice_ready())
{ {

View File

@ -49,6 +49,8 @@ struct AppState
void * lgrData; void * lgrData;
bool lgrResize; bool lgrResize;
SDL_Thread * t_frame;
const LG_Clipboard * lgc; const LG_Clipboard * lgc;
SpiceDataType cbType; SpiceDataType cbType;
struct ll * cbRequestList; struct ll * cbRequestList;