From 3ce4c3a0e4695e5accd6e9d40f284886f89bc671 Mon Sep 17 00:00:00 2001 From: Leonid Yuriev Date: Sat, 12 Oct 2019 10:42:27 +0300 Subject: [PATCH] mdbx-test: minor refine actor_poll() for Windows. Change-Id: Ic1d98ae9e6d8bd7534390b15682f0bc7d1e73fac --- test/osal-windows.cc | 55 ++++++++++++++++++++++---------------------- 1 file changed, 28 insertions(+), 27 deletions(-) diff --git a/test/osal-windows.cc b/test/osal-windows.cc index 1fecae87..0b158c0d 100644 --- a/test/osal-windows.cc +++ b/test/osal-windows.cc @@ -380,37 +380,38 @@ int osal_actor_poll(mdbx_pid_t &pid, unsigned timeout) { if (pair.second.second <= as_running) handles.push_back(pair.second.first); -loop: - DWORD rc = - MsgWaitForMultipleObjectsEx((DWORD)handles.size(), &handles[0], - (timeout > 60) ? 60 * 1000 : timeout * 1000, - QS_ALLINPUT | QS_ALLPOSTMESSAGE, 0); + while (true) { + DWORD rc = + MsgWaitForMultipleObjectsEx((DWORD)handles.size(), &handles[0], + (timeout > 60) ? 60 * 1000 : timeout * 1000, + QS_ALLINPUT | QS_ALLPOSTMESSAGE, 0); - if (rc == WAIT_OBJECT_0) { - logging::progress_canary(true); - goto loop; - } - if (rc == WAIT_OBJECT_0 + 1) { - logging::progress_canary(false); - goto loop; - } + if (rc == WAIT_OBJECT_0) { + logging::progress_canary(true); + continue; + } + if (rc == WAIT_OBJECT_0 + 1) { + logging::progress_canary(false); + continue; + } - if (rc >= WAIT_OBJECT_0 + 2 && rc < WAIT_OBJECT_0 + handles.size()) { - pid = 0; - for (const auto &pair : childs) - if (pair.second.first == handles[rc - WAIT_OBJECT_0]) { - pid = pair.first; - break; - } - return 0; - } + if (rc >= WAIT_OBJECT_0 + 2 && rc < WAIT_OBJECT_0 + handles.size()) { + pid = 0; + for (const auto &pair : childs) + if (pair.second.first == handles[rc - WAIT_OBJECT_0]) { + pid = pair.first; + break; + } + return 0; + } - if (rc == WAIT_TIMEOUT) { - pid = 0; - return 0; - } + if (rc == WAIT_TIMEOUT) { + pid = 0; + return 0; + } - return waitstatus2errcode(rc); + return waitstatus2errcode(rc); + } } void osal_yield(void) { SwitchToThread(); }