kernel/pipe: fix poll support
Two issues: - is_condition_met() was missing proper code for The K_POLL_TYPE_PIPE_DATA_AVAILABLE case - z_handle_obj_poll_events() was misplaced in z_impl_k_pipe_write() Note: I added support for the deprecated pipe implementation to is_condition_met() but that is untested. Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
This commit is contained in:
parent
e29c0c1783
commit
f087aa264e
2 changed files with 14 additions and 6 deletions
|
@ -186,12 +186,13 @@ int z_impl_k_pipe_write(struct k_pipe *pipe, const uint8_t *data, size_t len, k_
|
|||
break;
|
||||
}
|
||||
}
|
||||
#ifdef CONFIG_POLL
|
||||
z_handle_obj_poll_events(&pipe->poll_events,
|
||||
K_POLL_STATE_PIPE_DATA_AVAILABLE);
|
||||
#endif /* CONFIG_POLL */
|
||||
}
|
||||
|
||||
#ifdef CONFIG_POLL
|
||||
need_resched |= z_handle_obj_poll_events(&pipe->poll_events,
|
||||
K_POLL_STATE_PIPE_DATA_AVAILABLE);
|
||||
#endif /* CONFIG_POLL */
|
||||
|
||||
written += ring_buf_put(&pipe->buf, &data[written], len - written);
|
||||
if (likely(written == len)) {
|
||||
rc = written;
|
||||
|
|
|
@ -88,8 +88,15 @@ static inline bool is_condition_met(struct k_poll_event *event, uint32_t *state)
|
|||
}
|
||||
break;
|
||||
case K_POLL_TYPE_PIPE_DATA_AVAILABLE:
|
||||
*state = K_POLL_STATE_PIPE_DATA_AVAILABLE;
|
||||
return true;
|
||||
#ifdef CONFIG_PIPES
|
||||
if (event->pipe->bytes_used != 0) {
|
||||
#else
|
||||
if (!ring_buf_is_empty(&event->pipe->buf)) {
|
||||
#endif
|
||||
*state = K_POLL_STATE_PIPE_DATA_AVAILABLE;
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case K_POLL_TYPE_IGNORE:
|
||||
break;
|
||||
default:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue