Add 0 as valid g_obj_wait timeout instead of having it be equivalent to -1.

This commit is contained in:
Nexarian 2024-01-07 02:53:21 -05:00 committed by Christopher Pitstick
parent 63e963daf6
commit 584a894490
5 changed files with 10 additions and 9 deletions

View File

@ -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;
}

View File

@ -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);

View File

@ -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;

View File

@ -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: "

View File

@ -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,