From 9e9888bfb2393716ba04857e8dde7732e0bbdf18 Mon Sep 17 00:00:00 2001 From: Laurent Mazet Date: Sun, 8 Jun 2025 23:38:21 +0200 Subject: [PATCH] fix timeout in msec --- morep.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/morep.c b/morep.c index b86a6bd..11be582 100644 --- a/morep.c +++ b/morep.c @@ -531,17 +531,21 @@ int MOREP_Receive_timeout (int index, uint8_t *msgtype, uint8_t *buffer, int *le VERBOSE (morep, TRACE, PRINTF ("MOREP_Receive_timeout\n")); - if (MOREP_list[index]->used) { + if ((index < 0) || (index >= MAX_MOREP_NUMBER) || + (MOREP_list[index] == NULL) || (!MOREP_list[index]->used)) { + VERBOSE (morep, ERROR, PRINTF ("incorrect MOREP descriptor (%d)\n", index)); return -1; } + VERBOSE (morep, DEBUG, PRINTF ("working with MOREP descriptor %d (%d)\n", index, MOREP_list[index]->sock)); int fid = MOREP_list[index]->sock; fd_set rfds; - struct timeval tv = { 0, ms }; + struct timeval tv = { 0, ms * 1000}; FD_ZERO (&rfds); FD_SET (fid, &rfds); int retval = select (fid + 1, &rfds, NULL, NULL, &tv); + VERBOSE (morep, TRACE, PRINTF ("select: %d (%ld, %ld)\n", retval, tv.tv_sec, tv.tv_usec)); if (retval != 1) { return retval; } -- 2.30.2