]> git.sesse.net Git - plocate/blobdiff - io_uring_engine.cpp
uring: always pair io_uring_get_probe_ring and io_uring_free_probe
[plocate] / io_uring_engine.cpp
index ab9f411c7774ad7905bfbde901459540ee3c4a23..be9366037ae0dbd9e3ad2f34f7c9995513f1d20a 100644 (file)
@@ -41,12 +41,12 @@ IOUringEngine::IOUringEngine(size_t slop_bytes)
                if (!supports_stat) {
                        dprintf("io_uring on this kernel does not support statx(); will do synchronous access checking.\n");
                }
-               free(probe);
+               io_uring_free_probe(probe);
        }
 #endif
 }
 
-void IOUringEngine::submit_stat(const char *path, std::function<void()> cb)
+void IOUringEngine::submit_stat(const char *path [[maybe_unused]], std::function<void(bool)> cb [[maybe_unused]])
 {
        assert(supports_stat);
 
@@ -115,7 +115,7 @@ void IOUringEngine::submit_read_internal(io_uring_sqe *sqe, int fd, size_t len,
        ++pending_reads;
 }
 
-void IOUringEngine::submit_stat_internal(io_uring_sqe *sqe, char *path, std::function<void()> cb)
+void IOUringEngine::submit_stat_internal(io_uring_sqe *sqe, char *path, std::function<void(bool)> cb)
 {
        PendingRead *pending = new PendingRead;
        pending->op = OP_STAT;
@@ -123,7 +123,7 @@ void IOUringEngine::submit_stat_internal(io_uring_sqe *sqe, char *path, std::fun
        pending->stat.pathname = path;
        pending->stat.buf = new struct statx;
 
-       io_uring_prep_statx(sqe, /*fd=*/-1, pending->stat.pathname, AT_STATX_SYNC_AS_STAT, STATX_MODE, pending->stat.buf);
+       io_uring_prep_statx(sqe, /*fd=*/-1, pending->stat.pathname, AT_STATX_SYNC_AS_STAT | AT_SYMLINK_NOFOLLOW, STATX_MODE, pending->stat.buf);
        io_uring_sqe_set_data(sqe, pending);
        ++pending_reads;
 }
@@ -166,7 +166,7 @@ void IOUringEngine::finish()
                                --pending_reads;
 
                                size_t old_pending_reads = pending_reads;
-                               pending->stat_cb();
+                               pending->stat_cb(cqe->res == 0);
                                free(pending->stat.pathname);
                                delete pending->stat.buf;
                                delete pending;