From bb2170fcc8f64d41bdf03f914e583e2ec3ca46a7 Mon Sep 17 00:00:00 2001 From: Barr Date: Wed, 18 Jun 2025 14:17:15 +0300 Subject: [PATCH] Fix failed reads returning a buffer they never got When a read fails, it is not allocated a buffer and the BID is set to 0, before this fix, this causes the program to return buffer 0 to the available buffers and can cause multiple future SQEs to get the same buffer 0. --- io_uring_echo_server.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/io_uring_echo_server.c b/io_uring_echo_server.c index 775fc2b..9759511 100644 --- a/io_uring_echo_server.c +++ b/io_uring_echo_server.c @@ -149,8 +149,6 @@ int main(int argc, char *argv[]) { int bytes_read = cqe->res; int bid = cqe->flags >> 16; if (cqe->res <= 0) { - // read failed, re-add the buffer - add_provide_buf(&ring, bid, group_id); // connection closed or error close(conn_i.fd); } else {