authorgravatar for igor.anic@gmail.comIgor Anić <igor.anic@gmail.com> 2024-06-14 11:07:50+02:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-06-20 18:03:28-04:00
logb8890f8ee1cb36e425afd96c0058fc382eb7cf39
tree2f466ca56c6322dad34252fdeec0046428169786
parente03026507f6e3f0b60947d9859c1346f64f480b6

io_uring: don't assume completions order (2)

In my first [try](https://github.com/ziglang/zig/pull/20224) to fix 20212 I didn't reproduce bug on required kernel (6.9.2) and wrongly concluded that first two completions have different order on newer kernel. On my current kernel (6.5.0) order of completions is: send1, recv, send2. On 6.9.2 order is send1, send2, recv. This fix allows second two completions to arrive in any order. Tested on both kernels. Fixes: #20212

1 files changed, 7 insertions(+), 7 deletions(-)

lib/std/os/linux/IoUring.zig+7-7
......@@ -3524,12 +3524,7 @@ test "accept/connect/send_zc/recv" {
35243524 _ = try ring.recv(0xffffffff, socket_test_harness.server, .{ .buffer = buffer_recv[0..] }, 0);
35253525 try testing.expectEqual(@as(u32, 2), try ring.submit());
35263526
3527 var cqe_send, const cqe_recv = brk: {
3528 const cqe1 = try ring.copy_cqe();
3529 const cqe2 = try ring.copy_cqe();
3530 break :brk if (cqe1.user_data == 0xeeeeeeee) .{ cqe1, cqe2 } else .{ cqe2, cqe1 };
3531 };
3532
3527 var cqe_send = try ring.copy_cqe();
35333528 // First completion of zero-copy send.
35343529 // IORING_CQE_F_MORE, means that there
35353530 // will be a second completion event / notification for the
......@@ -3541,6 +3536,12 @@ test "accept/connect/send_zc/recv" {
35413536 .flags = linux.IORING_CQE_F_MORE,
35423537 }, cqe_send);
35433538
3539 cqe_send, const cqe_recv = brk: {
3540 const cqe1 = try ring.copy_cqe();
3541 const cqe2 = try ring.copy_cqe();
3542 break :brk if (cqe1.user_data == 0xeeeeeeee) .{ cqe1, cqe2 } else .{ cqe2, cqe1 };
3543 };
3544
35443545 try testing.expectEqual(linux.io_uring_cqe{
35453546 .user_data = 0xffffffff,
35463547 .res = buffer_recv.len,
......@@ -3550,7 +3551,6 @@ test "accept/connect/send_zc/recv" {
35503551
35513552 // Second completion of zero-copy send.
35523553 // IORING_CQE_F_NOTIF in flags signals that kernel is done with send_buffer
3553 cqe_send = try ring.copy_cqe();
35543554 try testing.expectEqual(linux.io_uring_cqe{
35553555 .user_data = 0xeeeeeeee,
35563556 .res = 0,