Properly catch and handle database errors
Do not use a singleton for the database. fix #3203
This commit is contained in:
+9
-10
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user