From 3bc2506d92f27b9386b3d5d70eb8fe1ffaa13902 Mon Sep 17 00:00:00 2001 From: Geoffrey McRae Date: Wed, 13 Dec 2017 21:06:48 +1100 Subject: [PATCH] [client] added clean client restart mechanisim --- client/main.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/client/main.c b/client/main.c index ba2c8a2d..5c8b7df8 100644 --- a/client/main.c +++ b/client/main.c @@ -146,17 +146,24 @@ int renderThread(void * unused) struct KVMFRHeader header; volatile uint32_t * updateCount = &state.shm->updateCount; - ivshmem_kick_irq(state.shm->guestID, 0); + const struct timespec s = + { + .tv_sec = 0, + .tv_nsec = 1000 + }; + + // flag the host that we are starting up this is important so that + // the host wakes up if it is waiting on an interrupt, the host will + // also send us the current mouse shape since we won't know it yet + __sync_or_and_fetch(&state.shm->flags, KVMFR_HEADER_FLAG_RESTART); + while(state.running && (state.shm->flags & KVMFR_HEADER_FLAG_RESTART)) + nanosleep(&s, NULL); + while(state.running) { // poll until we have a new frame, or we time out - while(header.updateCount == *updateCount && state.running) { - const struct timespec s = { - .tv_sec = 0, - .tv_nsec = 1000 - }; + while(header.updateCount == *updateCount && state.running) nanosleep(&s, NULL); - } if (!state.running) break;