From 584a8944901ccf2abd95212945d2e0d6a688f2f0 Mon Sep 17 00:00:00 2001 From: Nexarian Date: Sun, 7 Jan 2024 02:53:21 -0500 Subject: [PATCH] Add 0 as valid g_obj_wait timeout instead of having it be equivalent to -1. --- common/os_calls.c | 4 ++-- common/os_calls.h | 5 ++++- sesman/chansrv/chansrv.c | 4 ++-- sesman/sesexec/sesexec.c | 2 +- xrdp/xrdp_mm.c | 4 +--- 5 files changed, 10 insertions(+), 9 deletions(-) diff --git a/common/os_calls.c b/common/os_calls.c index d8062f72..60d7705f 100644 --- a/common/os_calls.c +++ b/common/os_calls.c @@ -1974,7 +1974,7 @@ g_obj_wait(tintptr *read_objs, int rcount, tintptr *write_objs, int wcount, handles[j++] = (HANDLE)(write_objs[i]); } - if (mstimeout < 1) + if (mstimeout < 0) { mstimeout = INFINITE; } @@ -2011,7 +2011,7 @@ g_obj_wait(tintptr *read_objs, int rcount, tintptr *write_objs, int wcount, } else { - if (mstimeout < 1) + if (mstimeout < 0) { mstimeout = -1; } diff --git a/common/os_calls.h b/common/os_calls.h index a9cf8f5d..02758e89 100644 --- a/common/os_calls.h +++ b/common/os_calls.h @@ -203,10 +203,13 @@ int g_delete_wait_obj(tintptr obj); * @param rcount Number of elements in read_objs * @param write_objs Array of write objects * @param rcount Number of elements in write_objs - * @param mstimeout Timeout in milliseconds. <= 0 means an infinite timeout. + * @param mstimeout Timeout in milliseconds. < 0 means an infinite timeout. * * @return 0 for success. The objects will need to be polled to * find out what is readable or writeable. + * + * An mstimeout of zero will return immediately, although + * error conditions may be checked for. */ int g_obj_wait(tintptr *read_objs, int rcount, tintptr *write_objs, int wcount, int mstimeout); diff --git a/sesman/chansrv/chansrv.c b/sesman/chansrv/chansrv.c index 31daff4c..80f0a231 100644 --- a/sesman/chansrv/chansrv.c +++ b/sesman/chansrv/chansrv.c @@ -1787,7 +1787,7 @@ main(int argc, char **argv) waiters[1] = g_exec_event; waiters[2] = g_sigchld_event; - if (g_obj_wait(waiters, 3, 0, 0, 0) != 0) + if (g_obj_wait(waiters, 3, 0, 0, -1) != 0) { LOG_DEVEL(LOG_LEVEL_ERROR, "main: error, g_obj_wait failed"); break; @@ -1814,7 +1814,7 @@ main(int argc, char **argv) while (g_thread_done_event > 0 && !g_is_wait_obj_set(g_thread_done_event)) { /* wait for thread to exit */ - if (g_obj_wait(&g_thread_done_event, 1, 0, 0, 0) != 0) + if (g_obj_wait(&g_thread_done_event, 1, 0, 0, -1) != 0) { LOG_DEVEL(LOG_LEVEL_ERROR, "main: error, g_obj_wait failed"); break; diff --git a/sesman/sesexec/sesexec.c b/sesman/sesexec/sesexec.c index 563a0695..3e9763dd 100644 --- a/sesman/sesexec/sesexec.c +++ b/sesman/sesexec/sesexec.c @@ -283,7 +283,7 @@ sesexec_main_loop(void) continue; } - if (g_obj_wait(robjs, robjs_count, NULL, 0, 0) != 0) + if (g_obj_wait(robjs, robjs_count, NULL, 0, -1) != 0) { /* should not get here */ LOG(LOG_LEVEL_WARNING, "sesexec_main_loop: " diff --git a/xrdp/xrdp_mm.c b/xrdp/xrdp_mm.c index 78a8d95c..42faea61 100644 --- a/xrdp/xrdp_mm.c +++ b/xrdp/xrdp_mm.c @@ -3155,9 +3155,7 @@ xrdp_mm_connect_sm(struct xrdp_mm *self) } #define MIN_MS_BETWEEN_FRAMES 40 -/* can not change this to zero yet, g_obj_wait in os_calls.c treats - everything less then 1 to mean wait forever */ -#define MIN_MS_TO_WAIT_FOR_MORE_UPDATES 1 +#define MIN_MS_TO_WAIT_FOR_MORE_UPDATES 0 /*****************************************************************************/ int xrdp_mm_get_wait_objs(struct xrdp_mm *self,