diff mbox series

[liburing,1/2] fixup poll-mshot-update

Message ID 20220721160406.1700508-2-dylany@fb.com (mailing list archive)
State New
Headers show
Series test: fix poll-mshot-update tests | expand

Commit Message

Dylan Yudaken July 21, 2022, 4:04 p.m. UTC
this test did not notice when poll was cancelled.

update it to notice, and rearm poll

Signed-off-by: Dylan Yudaken <dylany@fb.com>
---
 test/poll-mshot-update.c | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)
diff mbox series

Patch

diff --git a/test/poll-mshot-update.c b/test/poll-mshot-update.c
index caedb6fddc4b..e01befcfa7eb 100644
--- a/test/poll-mshot-update.c
+++ b/test/poll-mshot-update.c
@@ -75,6 +75,20 @@  static int arm_poll(struct io_uring *ring, int off)
 	return 0;
 }
 
+static int submit_arm_poll(struct io_uring *ring, int off)
+{
+	int ret;
+
+	ret = arm_poll(ring, off);
+	if (ret)
+		return ret;
+
+	ret = io_uring_submit(ring);
+	if (ret < 0)
+		return ret;
+	return ret == 1 ? 0 : -1;
+}
+
 static int reap_polls(struct io_uring *ring)
 {
 	struct io_uring_cqe *cqe;
@@ -106,6 +120,18 @@  static int reap_polls(struct io_uring *ring)
 		off = cqe->user_data;
 		if (off == 0x12345678)
 			goto seen;
+		if (!(cqe->flags & IORING_CQE_F_MORE)) {
+			/* need to re-arm poll */
+			ret = submit_arm_poll(ring, off);
+			if (ret)
+				break;
+			if (cqe->res <= 0) {
+				/* retry this one */
+				i--;
+				goto seen;
+			}
+		}
+
 		ret = read(p[off].fd[0], &c, 1);
 		if (ret != 1) {
 			if (ret == -1 && errno == EAGAIN)