diff --git a/main.cpp b/main.cpp index 62a0c042671e728fa3d5e2b9de03689214ff56e0..8b0ef299c91eb65c7ba57c52112fe7fd4c2db8dc 100644 --- a/main.cpp +++ b/main.cpp @@ -67,12 +67,23 @@ static void thread_func(pthread_barrier_t& init_barrier, unsigned id, bool direc struct io_uring_cqe* cqe; if (io_uring_peek_cqe(&ring, &cqe) < 0) err(EXIT_FAILURE, "failed to peek cqe"); - if (cqe->res < 0) { - errno = -cqe->res; + int res = cqe->res; + if (res < 0) { + errno = -res; err(EXIT_FAILURE, "%d: %sopening %s failed", id, direct ? "directly " : "", p->c_str()); } io_uring_cqe_seen(&ring, cqe); + + if (!direct) { + sqe = io_uring_get_sqe(&ring); + assert(sqe); + io_uring_prep_close(sqe, res); + sqe->flags |= IOSQE_CQE_SKIP_SUCCESS; + + submitted = io_uring_submit(&ring); + assert(submitted == 1); + } } }