From 18cc8d7cab879b846ac6c9d63679fd7793d28d47 Mon Sep 17 00:00:00 2001 From: Geoffrey McRae Date: Sun, 17 May 2020 11:54:07 +1000 Subject: [PATCH] [client] fix host wait logic and print more useful help --- VERSION | 2 +- client/src/main.c | 78 +++++++++++++++++++++-------------------------- repos/LGMP | 2 +- 3 files changed, 37 insertions(+), 45 deletions(-) diff --git a/VERSION b/VERSION index bbbfb3ad..1873aba9 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -B1-190-gb7ca3d7e37+1 \ No newline at end of file +B1-191-gfc0dbd8782+1 \ No newline at end of file diff --git a/client/src/main.c b/client/src/main.c index 7b32cf83..b73111ee 100644 --- a/client/src/main.c +++ b/client/src/main.c @@ -1448,31 +1448,37 @@ static int lg_run() lgWaitEvent(e_startup, TIMEOUT_INFINITE); LGMP_STATUS status; - while(true) - { - uint32_t udataSize; - KVMFR *udata; + uint32_t udataSize; + KVMFR *udata; + int waitCount = 0; + while(state.running) + { if ((status = lgmpClientInit(state.shm.mem, state.shm.size, &state.lgmp, &udataSize, (uint8_t **)&udata)) == LGMP_OK) break; if (status == LGMP_ERR_INVALID_SESSION || status == LGMP_ERR_INVALID_MAGIC) { - SDL_WaitEventTimeout(NULL, 1000); - continue; - } + if (waitCount++ == 0) + { + DEBUG_BREAK(); + DEBUG_INFO("The host application seems to not be running"); + DEBUG_INFO("Waiting for the host application to start..."); + } - if (udataSize != sizeof(KVMFR) || - memcmp(udata->magic, KVMFR_MAGIC, sizeof(udata->magic)) != 0 || - udata->version != KVMFR_VERSION) - { - DEBUG_BREAK(); - DEBUG_ERROR("The host application is not compatible with this client"); - DEBUG_ERROR("Expected KVMFR version %d", KVMFR_VERSION); - DEBUG_ERROR("This is not a Looking Glass error, do not report this"); - DEBUG_BREAK(); - return -1; + if (waitCount == 30) + { + DEBUG_BREAK(); + DEBUG_INFO("Please check the host application is running and is the correct version"); + DEBUG_INFO("Check the host log in your guest at %%TEMP%%\\looking-glass-host.txt"); + DEBUG_INFO("Continuing to wait..."); + } + + if (status == LGMP_ERR_INVALID_SESSION) + SDL_WaitEventTimeout(NULL, 1000); + + continue; } DEBUG_ERROR("lgmpClientInit Failed: %s", lgmpStatusString(status)); @@ -1482,6 +1488,18 @@ static int lg_run() if (!state.running) return -1; + if (udataSize != sizeof(KVMFR) || + memcmp(udata->magic, KVMFR_MAGIC, sizeof(udata->magic)) != 0 || + udata->version != KVMFR_VERSION) + { + DEBUG_BREAK(); + DEBUG_ERROR("The host application is not compatible with this client"); + DEBUG_ERROR("Expected KVMFR version %d", KVMFR_VERSION); + DEBUG_ERROR("This is not a Looking Glass error, do not report this"); + DEBUG_BREAK(); + return -1; + } + DEBUG_INFO("Host ready, starting session"); if (!lgCreateThread("cursorThread", cursorThread, NULL, &t_cursor)) @@ -1496,7 +1514,6 @@ static int lg_run() return -1; } - bool *closeAlert = NULL; while(state.running) { SDL_WaitEventTimeout(NULL, 1000); @@ -1506,31 +1523,6 @@ static int lg_run() DEBUG_WARN("Session is invalid, has the host shutdown?"); break; } - - (void)closeAlert; - /* - if (closeAlert == NULL) - { - if (state.kvmfr->flags & KVMFR_HEADER_FLAG_PAUSED) - { - if (state.lgr && params.showAlerts) - state.lgr->on_alert( - state.lgrData, - LG_ALERT_WARNING, - "Stream Paused", - &closeAlert - ); - } - } - else - { - if (!(state.kvmfr->flags & KVMFR_HEADER_FLAG_PAUSED)) - { - *closeAlert = true; - closeAlert = NULL; - } - } - */ } return 0; diff --git a/repos/LGMP b/repos/LGMP index 61c9178c..520350a8 160000 --- a/repos/LGMP +++ b/repos/LGMP @@ -1 +1 @@ -Subproject commit 61c9178c87df46f39a817e63eb85afe2a131e51d +Subproject commit 520350a8af533a8ef307da13fa95a19d5ae78762