Browse Source

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>
pull/77495/merge
Nicolas Pitre 3 months ago committed by Benjamin Cabé
parent
commit
f087aa264e
  1. 7
      kernel/pipe.c
  2. 11
      kernel/poll.c

7
kernel/pipe.c

@ -186,11 +186,12 @@ int z_impl_k_pipe_write(struct k_pipe *pipe, const uint8_t *data, size_t len, k_ @@ -186,11 +186,12 @@ 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);
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)) {

11
kernel/poll.c

@ -88,8 +88,15 @@ static inline bool is_condition_met(struct k_poll_event *event, uint32_t *state) @@ -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…
Cancel
Save