Commit f087aa26 authored by Nicolas Pitre's avatar Nicolas Pitre Committed by Benjamin Cabé
Browse files

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: default avatarNicolas Pitre <npitre@baylibre.com>
parent e29c0c17
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -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,
		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)) {
+9 −2
Original line number Diff line number Diff line
@@ -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:
#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: