From: Laurent Mazet Date: Sun, 8 Jun 2025 21:38:21 +0000 (+0200) Subject: fix timeout in msec X-Git-Tag: v1.0~10 X-Git-Url: https://secure.softndesign.org/git/?a=commitdiff_plain;h=9e9888bfb2393716ba04857e8dde7732e0bbdf18;p=morep.git fix timeout in msec --- 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; }