]> git.sesse.net Git - plocate/commitdiff
Add debug output if io_uring initialization fails.
authorSteinar H. Gunderson <steinar+git@gunderson.no>
Sun, 11 Oct 2020 17:09:18 +0000 (19:09 +0200)
committerSteinar H. Gunderson <steinar+git@gunderson.no>
Sun, 11 Oct 2020 17:09:18 +0000 (19:09 +0200)
dprintf.h [new file with mode: 0644]
io_uring_engine.cpp
plocate.cpp

diff --git a/dprintf.h b/dprintf.h
new file mode 100644 (file)
index 0000000..2ed6f22
--- /dev/null
+++ b/dprintf.h
@@ -0,0 +1,16 @@
+#ifndef _DPRINTF_H
+#define _DPRINTF_H 1
+
+#include <stdio.h>
+
+extern bool use_debug;
+
+// Debug printf.
+#define dprintf(...) \
+       do { \
+               if (use_debug) { \
+                       fprintf(stderr, __VA_ARGS__); \
+               } \
+       } while (false)
+
+#endif  // !defined(_DPRINTF_H)
index fc51abab6a75e23143235f555e8edec82547529b..03160b12a4abb1f04e83a84acfcf84d7589ad1f1 100644 (file)
@@ -5,6 +5,7 @@
 #ifndef WITHOUT_URING
 #include <liburing.h>
 #endif
+#include "dprintf.h"
 #include "io_uring_engine.h"
 
 #include <functional>
@@ -20,8 +21,12 @@ IOUringEngine::IOUringEngine(size_t slop_bytes)
 {
 #ifdef WITHOUT_URING
        int ret = -1;
+       dprintf("Compiled without liburing support; not using io_uring.\n");
 #else
        int ret = io_uring_queue_init(queue_depth, &ring, 0);
+       if (ret < 0) {
+               dprintf("io_uring_queue_init() failed; not using io_uring.\n");
+       }
 #endif
        using_uring = (ret >= 0);
 }
index de7bd7a0eafc1073b1bfdc72b53166f88d0535ea..66dfa918728ff7248f0705a92b857bca20e9ad62 100644 (file)
@@ -1,4 +1,5 @@
 #include "db.h"
+#include "dprintf.h"
 #include "io_uring_engine.h"
 #include "parse_trigrams.h"
 #include "turbopfor.h"
 using namespace std;
 using namespace std::chrono;
 
-#define dprintf(...) \
-       do { \
-               if (use_debug) { \
-                       fprintf(stderr, __VA_ARGS__); \
-               } \
-       } while (false)
-
 #define DEFAULT_DBPATH "/var/lib/mlocate/plocate.db"
 
 const char *dbpath = DEFAULT_DBPATH;