Skip to content

Commit f087aa2

Browse files
Nicolas Pitrekartben
Nicolas Pitre
authored andcommitted
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 <[email protected]>
1 parent e29c0c1 commit f087aa2

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

kernel/pipe.c

+4-3
Original file line numberDiff line numberDiff line change
@@ -186,11 +186,12 @@ int z_impl_k_pipe_write(struct k_pipe *pipe, const uint8_t *data, size_t len, k_
186186
break;
187187
}
188188
}
189+
}
190+
189191
#ifdef CONFIG_POLL
190-
z_handle_obj_poll_events(&pipe->poll_events,
191-
K_POLL_STATE_PIPE_DATA_AVAILABLE);
192+
need_resched |= z_handle_obj_poll_events(&pipe->poll_events,
193+
K_POLL_STATE_PIPE_DATA_AVAILABLE);
192194
#endif /* CONFIG_POLL */
193-
}
194195

195196
written += ring_buf_put(&pipe->buf, &data[written], len - written);
196197
if (likely(written == len)) {

kernel/poll.c

+9-2
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,15 @@ static inline bool is_condition_met(struct k_poll_event *event, uint32_t *state)
8888
}
8989
break;
9090
case K_POLL_TYPE_PIPE_DATA_AVAILABLE:
91-
*state = K_POLL_STATE_PIPE_DATA_AVAILABLE;
92-
return true;
91+
#ifdef CONFIG_PIPES
92+
if (event->pipe->bytes_used != 0) {
93+
#else
94+
if (!ring_buf_is_empty(&event->pipe->buf)) {
95+
#endif
96+
*state = K_POLL_STATE_PIPE_DATA_AVAILABLE;
97+
return true;
98+
}
99+
break;
93100
case K_POLL_TYPE_IGNORE:
94101
break;
95102
default:

0 commit comments

Comments
 (0)