From 4c1b9abe7e230a39b119bdc45ebcd5e677fad488 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Tue, 12 Jul 2016 00:31:57 +0200 Subject: Properly catch and handle database errors Do not use a singleton for the database. fix #3203 --- src/main.cpp | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'src/main.cpp') diff --git a/src/main.cpp b/src/main.cpp index ed05d36..422219a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3,22 +3,15 @@ #include #include #include -#include #include - -#include -#include -#include - -#include +#include #ifdef CARES_FOUND # include #endif -#ifdef SYSTEMD_FOUND -# include -#endif +#include +#include // A flag set by the SIGINT signal handler. static volatile std::atomic stop(false); @@ -71,6 +64,12 @@ int main(int ac, char** av) if (hostname.empty()) return config_help("hostname"); + try { + open_database(); + } catch (...) { + return 1; + } + // Block the signals we want to manage. They will be unblocked only during // the epoll_pwait or ppoll calls. This avoids some race conditions, // explained in man 2 pselect on linux -- cgit v1.2.3