From 6b3037106a3af12e653ac6322b9208e569e3b39a Mon Sep 17 00:00:00 2001 From: llmII Date: Thu, 30 Sep 2021 06:56:09 -0500 Subject: [PATCH] Fix #822 - kqueue hang in suite 9. Priorly we only checked exactly one state when an event was received. This was incorrect. A state may have a next state, an action to take after the first in the list of states has been taken. This change acknowledges that and makes the code work with the state list vs just the head of the list. --- src/core/ev.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/core/ev.c b/src/core/ev.c index 44c73a4b..21b5df94 100644 --- a/src/core/ev.c +++ b/src/core/ev.c @@ -1709,7 +1709,8 @@ void janet_loop1_impl(int has_timeout, JanetTimestamp timeout) { } else { JanetStream *stream = p; JanetListenerState *state = stream->state; - if (NULL != state) { + while (NULL != state) { + JanetListenerState *next_state = state->_next; state->event = events + i; JanetAsyncStatus statuses[4]; for (int i = 0; i < 4; i++) @@ -1730,6 +1731,8 @@ void janet_loop1_impl(int has_timeout, JanetTimestamp timeout) { statuses[2] == JANET_ASYNC_STATUS_DONE || statuses[3] == JANET_ASYNC_STATUS_DONE) janet_unlisten(state, 0); + + state = next_state; } } }