queue: k_queue_cancel_wait: Fix not interrupting other threads

When k_poll is being used k_queue_cancel_wait shall mark the state as
K_POLL_STATE_NOT_READY so other threads will get properly notified with
a NULL pointer return.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This commit is contained in:
Luiz Augusto von Dentz 2017-10-17 15:37:26 +03:00 committed by Anas Nashif
commit 48fadfe623

View file

@ -68,11 +68,9 @@ static void prepare_thread_to_run(struct k_thread *thread, void *data)
#endif /* CONFIG_POLL */ #endif /* CONFIG_POLL */
/* returns 1 if a reschedule must take place, 0 otherwise */ /* returns 1 if a reschedule must take place, 0 otherwise */
static inline int handle_poll_events(struct k_queue *queue) static inline int handle_poll_events(struct k_queue *queue, u32_t state)
{ {
#ifdef CONFIG_POLL #ifdef CONFIG_POLL
u32_t state = K_POLL_STATE_DATA_AVAILABLE;
return _handle_obj_poll_events(&queue->poll_events, state); return _handle_obj_poll_events(&queue->poll_events, state);
#else #else
return 0; return 0;
@ -95,7 +93,7 @@ void k_queue_cancel_wait(struct k_queue *queue)
} }
} }
#else #else
if (handle_poll_events(queue)) { if (handle_poll_events(queue, K_POLL_STATE_NOT_READY)) {
(void)_Swap(key); (void)_Swap(key);
return; return;
} }
@ -126,7 +124,7 @@ void k_queue_insert(struct k_queue *queue, void *prev, void *data)
sys_slist_insert(&queue->data_q, prev, data); sys_slist_insert(&queue->data_q, prev, data);
#if defined(CONFIG_POLL) #if defined(CONFIG_POLL)
if (handle_poll_events(queue)) { if (handle_poll_events(queue, K_POLL_STATE_DATA_AVAILABLE)) {
(void)_Swap(key); (void)_Swap(key);
return; return;
} }
@ -171,7 +169,7 @@ void k_queue_append_list(struct k_queue *queue, void *head, void *tail)
} }
#else #else
sys_slist_append_list(&queue->data_q, head, tail); sys_slist_append_list(&queue->data_q, head, tail);
if (handle_poll_events(queue)) { if (handle_poll_events(queue, K_POLL_STATE_DATA_AVAILABLE)) {
(void)_Swap(key); (void)_Swap(key);
return; return;
} }