Skip to content

Commit bc59ae1

Browse files
committed
ATRINIX: Clear WAKE list upon timeout
Or next wait would return the port even in case of another timeout
1 parent 84ed8b5 commit bc59ae1

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/core/c-port.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,7 @@ xx*/ REBINT Wait_Device(REBREQ *req, REBCNT timeout)
286286
*/ void Sieve_Ports(REBSER *ports)
287287
/*
288288
** Remove all ports not found in the WAKE list.
289+
** ports could be NULL, in which case the WAKE list is cleared.
289290
**
290291
***********************************************************************/
291292
{
@@ -299,7 +300,7 @@ xx*/ REBINT Wait_Device(REBREQ *req, REBCNT timeout)
299300
waked = VAL_BLK_SKIP(port, STD_PORT_DATA);
300301
if (!IS_BLOCK(waked)) return;
301302

302-
for (n = 0; n < SERIES_TAIL(ports);) {
303+
for (n = 0; ports && n < SERIES_TAIL(ports);) {
303304
val = BLK_SKIP(ports, n);
304305
if (IS_PORT(val)) {
305306
ASSERT(VAL_TAIL(waked) != 0, RP_IO_ERROR);

src/core/n-io.c

+4-1
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,10 @@ static REBSER *Read_All_File(char *fname)
371371
if (ports) Set_Block(D_RET, ports);
372372

373373
// Process port events [stack-move]:
374-
if (!Wait_Ports(ports, timeout)) return R_NONE;
374+
if (!Wait_Ports(ports, timeout)) {
375+
Sieve_Ports(NULL); /* just reset the waked list */
376+
return R_NONE;
377+
}
375378
if (!ports) return R_NONE;
376379
DS_RELOAD(ds);
377380

0 commit comments

Comments
 (0)