Skip to content

Commit

Permalink
Add 0 as valid g_obj_wait timeout instead of having it be equivalent …
Browse files Browse the repository at this point in the history
…to -1.
  • Loading branch information
Nexarian committed Jan 8, 2024
1 parent c23bf5b commit d260c26
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 9 deletions.
4 changes: 2 additions & 2 deletions common/os_calls.c
Original file line number Diff line number Diff line change
Expand Up @@ -1979,7 +1979,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;
}
Expand Down Expand Up @@ -2016,7 +2016,7 @@ g_obj_wait(tintptr *read_objs, int rcount, tintptr *write_objs, int wcount,
}
else
{
if (mstimeout < 1)
if (mstimeout < 0)
{
mstimeout = -1;
}
Expand Down
5 changes: 4 additions & 1 deletion common/os_calls.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions sesman/chansrv/chansrv.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion sesman/sesexec/sesexec.c
Original file line number Diff line number Diff line change
Expand Up @@ -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: "
Expand Down
4 changes: 1 addition & 3 deletions xrdp/xrdp_mm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit d260c26

Please sign in to comment.