https://linen.dev/ logo
I've been experimenting a bit with `io_uring_prep_...
# general
c
I've been experimenting a bit with
io_uring_prep_shutdown
to see how it interacts with various other io operations. i set up this tcp server which accepts a client, sends it 1mb, then closes the socket. the client on the other hand, connects, waits for enough milliseconds to allow the socket to fill up with the 1mb of data, then shuts down the socket's read side, and starts issuing `io_uring_prep_recv`s. And during the reaping of CQEs I get these:
Copy code
info: recv: .{ .user_data = recv, .res = 128000, .flags = 4 }
info: recv: .{ .user_data = recv, .res = 95232, .flags = 4 }
info: recv: .{ .user_data = recv, .res = 411136, .flags = 4 }
info: recv: .{ .user_data = recv, .res = 285696, .flags = 4 }
info: recv: .{ .user_data = recv, .res = 128512, .flags = 4 } // received EXACTLY one MB up to here.
info: recv: .{ .user_data = recv, .res = 0, .flags = 4 }
the flags = 4 is for
IORING_CQE_F_SOCK_NONEMPTY
which i found strange in the last CQE with res = 0 since there is no more data to read but it made me suspect that the server closing the socket is probably what's causing it, and it turns out my intuition is correct, here's what it looks like when the server doesn't close the client socket:
Copy code
info: recv: .{ .user_data = 2, .res = 128000, .flags = 4 }
info: recv: .{ .user_data = 2, .res = 95232, .flags = 4 }
info: recv: .{ .user_data = 2, .res = 411136, .flags = 4 }
info: recv: .{ .user_data = 2, .res = 285696, .flags = 4 }
info: recv: .{ .user_data = 2, .res = 128512, .flags = 0 }
info: recv: .{ .user_data = 2, .res = 0, .flags = 0 }
can someone confirm whether
IORING_CQE_F_SOCK_NONEMPTY
has some sort of dependence on TCP segments like FIN?