From: Steinar H. Gunderson Date: Sun, 11 Oct 2020 17:09:18 +0000 (+0200) Subject: Add debug output if io_uring initialization fails. X-Git-Tag: 1.0.0~3 X-Git-Url: https://git.sesse.net/?p=plocate;a=commitdiff_plain;h=99a0a43a777176583f3525e11ef62185dd2be740 Add debug output if io_uring initialization fails. --- diff --git a/dprintf.h b/dprintf.h new file mode 100644 index 0000000..2ed6f22 --- /dev/null +++ b/dprintf.h @@ -0,0 +1,16 @@ +#ifndef _DPRINTF_H +#define _DPRINTF_H 1 + +#include + +extern bool use_debug; + +// Debug printf. +#define dprintf(...) \ + do { \ + if (use_debug) { \ + fprintf(stderr, __VA_ARGS__); \ + } \ + } while (false) + +#endif // !defined(_DPRINTF_H) diff --git a/io_uring_engine.cpp b/io_uring_engine.cpp index fc51aba..03160b1 100644 --- a/io_uring_engine.cpp +++ b/io_uring_engine.cpp @@ -5,6 +5,7 @@ #ifndef WITHOUT_URING #include #endif +#include "dprintf.h" #include "io_uring_engine.h" #include @@ -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); } diff --git a/plocate.cpp b/plocate.cpp index de7bd7a..66dfa91 100644 --- a/plocate.cpp +++ b/plocate.cpp @@ -1,4 +1,5 @@ #include "db.h" +#include "dprintf.h" #include "io_uring_engine.h" #include "parse_trigrams.h" #include "turbopfor.h" @@ -33,13 +34,6 @@ 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;