io-uring.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH liburing 1/1] tests: fix poll-mshot-update
@ 2021-08-24 17:38 Pavel Begunkov
  2021-08-24 18:04 ` Jens Axboe
  0 siblings, 1 reply; 2+ messages in thread
From: Pavel Begunkov @ 2021-08-24 17:38 UTC (permalink / raw)
  To: Jens Axboe, io-uring

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@gmail.com>
---
 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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH liburing 1/1] tests: fix poll-mshot-update
  2021-08-24 17:38 [PATCH liburing 1/1] tests: fix poll-mshot-update Pavel Begunkov
@ 2021-08-24 18:04 ` Jens Axboe
  0 siblings, 0 replies; 2+ messages in thread
From: Jens Axboe @ 2021-08-24 18:04 UTC (permalink / raw)
  To: Pavel Begunkov, io-uring

On 8/24/21 11:38 AM, Pavel Begunkov wrote:
> 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.

Good catch!

-- 
Jens Axboe


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-08-24 18:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-24 17:38 [PATCH liburing 1/1] tests: fix poll-mshot-update Pavel Begunkov
2021-08-24 18:04 ` Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).