From e66ed4751520bff5d816f81a9e740dda3b74e64b Mon Sep 17 00:00:00 2001 From: Vitaliy Filippov Date: Tue, 2 Feb 2021 01:26:54 +0300 Subject: [PATCH] Clear SQEs before returning them to the caller to prevent erroneous double submissions --- ringloop.cpp | 3 +++ ringloop.h | 3 +++ 2 files changed, 6 insertions(+) diff --git a/ringloop.cpp b/ringloop.cpp index d28b0a69..c7ab4cbe 100644 --- a/ringloop.cpp +++ b/ringloop.cpp @@ -77,7 +77,10 @@ void ring_loop_t::loop() dl.callback(&dl); } else + { + printf("Warning: empty callback in SQE\n"); free_ring_data[free_ring_data_ptr++] = d - ring_datas; + } io_uring_cqe_seen(&ring, cqe); } while (get_sqe_queue.size() > 0) diff --git a/ringloop.h b/ringloop.h index 350bcaf1..e52623f6 100644 --- a/ringloop.h +++ b/ringloop.h @@ -142,7 +142,10 @@ public: return NULL; struct io_uring_sqe* sqe = io_uring_get_sqe(&ring); if (sqe) + { + *sqe = { 0 }; io_uring_sqe_set_data(sqe, ring_datas + free_ring_data[--free_ring_data_ptr]); + } return sqe; } inline int wait_sqe(std::function cb)