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 <walsh.benj@gmail.com>
This commit is contained in:
Benjamin Walsh 2017-02-09 14:55:44 -05:00 committed by Anas Nashif
commit 2014ff162e

View file

@ -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;