mirror of
https://github.com/gnif/LookingGlass.git
synced 2025-12-20 19:50:11 +00:00
[client] added ivshmem_process thread and fixed shutdown behaviour
This commit is contained in:
@@ -327,13 +327,32 @@ int renderThread(void * unused)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ivshmemThread(void * arg)
|
||||
{
|
||||
while(state.running)
|
||||
if (!ivshmem_process())
|
||||
{
|
||||
if (state.running)
|
||||
{
|
||||
state.running = false;
|
||||
DEBUG_ERROR("failed to process ivshmem messages");
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int spiceThread(void * arg)
|
||||
{
|
||||
while(state.running)
|
||||
if (!spice_process())
|
||||
{
|
||||
state.running = false;
|
||||
DEBUG_ERROR("Failed to process spice messages");
|
||||
if (state.running)
|
||||
{
|
||||
state.running = false;
|
||||
DEBUG_ERROR("failed to process spice messages");
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -463,9 +482,10 @@ int main(int argc, char * argv[])
|
||||
memset(&state, 0, sizeof(state));
|
||||
state.running = true;
|
||||
|
||||
int shm_fd = 0;
|
||||
SDL_Thread *t_spice = NULL;
|
||||
SDL_Thread *t_event = NULL;
|
||||
int shm_fd = 0;
|
||||
SDL_Thread *t_ivshmem = NULL;
|
||||
SDL_Thread *t_spice = NULL;
|
||||
SDL_Thread *t_event = NULL;
|
||||
|
||||
while(1)
|
||||
{
|
||||
@@ -475,6 +495,12 @@ int main(int argc, char * argv[])
|
||||
break;
|
||||
}
|
||||
|
||||
if (!(t_ivshmem = SDL_CreateThread(ivshmemThread, "ivshmemThread", NULL)))
|
||||
{
|
||||
DEBUG_ERROR("ivshmem create thread failed");
|
||||
break;
|
||||
}
|
||||
|
||||
state.shm = (struct KVMGFXHeader *)ivshmem_get_map();
|
||||
if (!state.shm)
|
||||
{
|
||||
@@ -519,6 +545,12 @@ int main(int argc, char * argv[])
|
||||
if (t_event)
|
||||
SDL_WaitThread(t_event, NULL);
|
||||
|
||||
// this needs to happen here to abort any waiting reads
|
||||
// as ivshmem uses recvmsg which has no timeout
|
||||
ivshmem_disconnect();
|
||||
if (t_ivshmem)
|
||||
SDL_WaitThread(t_ivshmem, NULL);
|
||||
|
||||
if (t_spice)
|
||||
SDL_WaitThread(t_spice, NULL);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user