From 2014ff162e85e98c6e60981126bf54f16199f7d0 Mon Sep 17 00:00:00 2001 From: Benjamin Walsh Date: Thu, 9 Feb 2017 14:55:44 -0500 Subject: [PATCH] kernel/poll: fix registrations that were not always cleared Poll events were getting registered even when polling conditions had already been met, but events with conditions met did not register and did not increment the number of events registered. This caused a possible discrepancy between the number of events registered and the position of the last event registered in the events array. As soon as one event condition is met, the next ones in the array should not get registered even if their condition is not met. This is what the code does now. Change-Id: Ibcc3b135ec9d3cf463beb9da3f641fec962b34bf Signed-off-by: Benjamin Walsh --- kernel/poll.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/poll.c b/kernel/poll.c index efb4d2ccc45..8c0f89f1cc4 100644 --- a/kernel/poll.c +++ b/kernel/poll.c @@ -198,7 +198,7 @@ int k_poll(struct k_poll_event *events, int num_events, int32_t timeout) if (is_condition_met(&events[ii], &state)) { set_event_ready(&events[ii], state); clear_polling_state(_current); - } else if (timeout != K_NO_WAIT && !in_use) { + } else if (timeout != K_NO_WAIT && is_polling() && !in_use) { rc = register_event(&events[ii]); if (rc == 0) { events[ii].poller = &poller;