[PATCH liburing 1/1] tests: fix poll-mshot-update

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



poll-mshot-update constantly hangs. Apparently, the reason is
reap_polls() clearing ->triggered flags racing with trigger_polls()
setting them. So, reinit the flags only after joining the thread.

Also, replace magic constants with proper identificators, e.g.
1 -> IORING_POLL_ADD_MULTI.

Signed-off-by: Pavel Begunkov <asml.silence@xxxxxxxxx>
---
 test/poll-mshot-update.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/test/poll-mshot-update.c b/test/poll-mshot-update.c
index a3e4951..6bf4679 100644
--- a/test/poll-mshot-update.c
+++ b/test/poll-mshot-update.c
@@ -71,7 +71,7 @@ static int arm_poll(struct io_uring *ring, int off)
 	}
 
 	io_uring_prep_poll_add(sqe, p[off].fd[0], POLLIN);
-	sqe->len = 1;
+	sqe->len = IORING_POLL_ADD_MULTI;
 	sqe->user_data = off;
 	return 0;
 }
@@ -88,7 +88,7 @@ static int reap_polls(struct io_uring *ring)
 		sqe = io_uring_get_sqe(ring);
 		/* update event */
 		io_uring_prep_poll_update(sqe, (void *)(unsigned long)i, NULL,
-					  POLLIN, 2);
+					  POLLIN, IORING_POLL_UPDATE_EVENTS);
 		sqe->user_data = 0x12345678;
 	}
 
@@ -107,7 +107,6 @@ static int reap_polls(struct io_uring *ring)
 		off = cqe->user_data;
 		if (off == 0x12345678)
 			goto seen;
-		p[off].triggered = 0;
 		ret = read(p[off].fd[0], &c, 1);
 		if (ret != 1) {
 			if (ret == -1 && errno == EAGAIN)
@@ -195,7 +194,7 @@ int main(int argc, char *argv[])
 	struct io_uring_params params = { };
 	struct rlimit rlim;
 	pthread_t thread;
-	int i, ret;
+	int i, j, ret;
 
 	if (argc > 1)
 		return 0;
@@ -256,6 +255,9 @@ int main(int argc, char *argv[])
 		if (ret)
 			goto err;
 		pthread_join(thread, NULL);
+
+		for (j = 0; j < NFILES; j++)
+			p[j].triggered = 0;
 	}
 
 	io_uring_queue_exit(&ring);
-- 
2.32.0




[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux