public inbox for [email protected]
 help / color / mirror / Atom feed
From: Pavel Begunkov <[email protected]>
To: Jens Axboe <[email protected]>, [email protected]
Subject: [PATCH liburing 1/1] tests: fix poll-mshot-update
Date: Tue, 24 Aug 2021 18:38:47 +0100	[thread overview]
Message-ID: <7e588f712ec61e0ddc619ce016d1c3b9445716e1.1629826707.git.asml.silence@gmail.com> (raw)

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 <[email protected]>
---
 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


             reply	other threads:[~2021-08-24 17:58 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-24 17:38 Pavel Begunkov [this message]
2021-08-24 18:04 ` [PATCH liburing 1/1] tests: fix poll-mshot-update Jens Axboe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7e588f712ec61e0ddc619ce016d1c3b9445716e1.1629826707.git.asml.silence@gmail.com \
    [email protected] \
    [email protected] \
    [email protected] \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox