Properly catch and handle database errors

Do not use a singleton for the database.

fix #3203
This commit is contained in:
louiz’
2016-07-12 00:31:57 +02:00
parent 03feb403f8
commit 4c1b9abe7e
6 changed files with 47 additions and 40 deletions
+9 -10
View File
@@ -3,22 +3,15 @@
#include <network/poller.hpp>
#include <config/config.hpp>
#include <logger/logger.hpp>
#include <utils/reload.hpp>
#include <utils/xdg.hpp>
#include <iostream>
#include <memory>
#include <atomic>
#include <signal.h>
#include <utils/reload.hpp>
#ifdef CARES_FOUND
# include <network/dns_handler.hpp>
#endif
#ifdef SYSTEMD_FOUND
# include <systemd/sd-daemon.h>
#endif
#include <atomic>
#include <signal.h>
// A flag set by the SIGINT signal handler.
static volatile std::atomic<bool> 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