aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Axboe <axboe@kernel.dk>2024-04-19 17:47:26 -0600
committerJens Axboe <axboe@kernel.dk>2024-04-19 17:47:26 -0600
commitbd527a50ed5f49d4bedf7540c12319ba18e5eac3 (patch)
tree95ede141e977bbaac53d5ec58bffc281c626bdf0
parentf4281698fd966e6de665c1fb144594c1420f9e73 (diff)
downloadliburing-bd527a50ed5f49d4bedf7540c12319ba18e5eac3.tar.gz
t/socket-io-cmd: do single retry for SIOCINQ
Sometimes we find legitimate data in the socket, which is a bit of a mystery, but it should not fail the test case as the data is indeed there and it isn't a test failure. It just arrives between the ioctl and io_uring SIOCINQ. Add a single retry in case this happens, as it should not fail the test case. Link: https://github.com/axboe/liburing/issues/1136 Signed-off-by: Jens Axboe <axboe@kernel.dk>
-rw-r--r--test/socket-io-cmd.c25
1 files changed, 17 insertions, 8 deletions
diff --git a/test/socket-io-cmd.c b/test/socket-io-cmd.c
index ba1f104..1c19a02 100644
--- a/test/socket-io-cmd.c
+++ b/test/socket-io-cmd.c
@@ -154,7 +154,7 @@ static int run_test_raw(void)
int ioctl_siocoutq, ioctl_siocinq;
int uring_siocoutq, uring_siocinq;
struct io_uring ring;
- int sock, error;
+ int retry = 0, sock, error;
sock = socket(PF_INET, SOCK_RAW, IPPROTO_TCP);
if (sock == -1) {
@@ -163,6 +163,14 @@ static int run_test_raw(void)
return T_EXIT_SKIP;
}
+ /* Get the same operation using uring cmd */
+ error = t_create_ring(1, &ring, 0);
+ if (error == T_SETUP_SKIP)
+ return error;
+ else if (error != T_SETUP_OK)
+ return T_EXIT_FAIL;
+
+again:
/* Simple SIOCOUTQ using ioctl */
error = ioctl(sock, SIOCOUTQ, &ioctl_siocoutq);
if (error < 0) {
@@ -176,13 +184,6 @@ static int run_test_raw(void)
return T_EXIT_FAIL;
}
- /* Get the same operation using uring cmd */
- error = t_create_ring(1, &ring, 0);
- if (error == T_SETUP_SKIP)
- return error;
- else if (error != T_SETUP_OK)
- return T_EXIT_FAIL;
-
create_sqe_and_submit(&ring, sock, SOCKET_URING_OP_SIOCOUTQ);
uring_siocoutq = receive_cqe(&ring);
@@ -191,11 +192,19 @@ static int run_test_raw(void)
/* Compare that both values (ioctl and uring CMD) should be similar */
if (uring_siocoutq != ioctl_siocoutq) {
+ if (!retry) {
+ retry = 1;
+ goto again;
+ }
fprintf(stderr, "values does not match: %d != %d\n",
uring_siocoutq, ioctl_siocoutq);
return T_EXIT_FAIL;
}
if (uring_siocinq != ioctl_siocinq) {
+ if (!retry) {
+ retry = 1;
+ goto again;
+ }
fprintf(stderr, "values does not match: %d != %d\n",
uring_siocinq, ioctl_siocinq);
return T_EXIT_FAIL;