From 233b7755ae55bdc9ce54753d30575d55a4970091 Mon Sep 17 00:00:00 2001 From: Geoffrey McRae Date: Wed, 13 Dec 2017 21:56:33 +1100 Subject: [PATCH] [client] moved host startup sync before window creation --- client/main.c | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/client/main.c b/client/main.c index 5c8b7df8..6262755c 100644 --- a/client/main.c +++ b/client/main.c @@ -146,24 +146,18 @@ int renderThread(void * unused) struct KVMFRHeader header; volatile uint32_t * updateCount = &state.shm->updateCount; - 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 + }; nanosleep(&s, NULL); + } if (!state.running) break; @@ -752,6 +746,15 @@ int run() state.shmSize = ivshmem_get_map_size(); state.shm->hostID = ivshmem_get_id(); + // 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 + DEBUG_INFO("Waiting for host to signal it's ready..."); + __sync_or_and_fetch(&state.shm->flags, KVMFR_HEADER_FLAG_RESTART); + while(state.running && (state.shm->flags & KVMFR_HEADER_FLAG_RESTART)) + usleep(1000); + DEBUG_INFO("Host ready, starting session"); + if (params.useSpice) { if (!spice_connect(params.spiceHost, params.spicePort, ""))