Clean up after dnsmasq errors (port not available config errors, etc.)

Signed-off-by: DL6ER <dl6er@dl6er.de>
This commit is contained in:
DL6ER
2021-02-17 13:44:31 +01:00
parent 8244043ca1
commit 70ee90ebfc
3 changed files with 18 additions and 18 deletions
+6 -12
View File
@@ -169,18 +169,12 @@ pid_t FTL_gettid(void)
void cleanup(const int ret)
{
// Terminate threads before closing database connections and finishing shared memory
if(telnet_listenthreadv4 != 0u)
pthread_cancel(telnet_listenthreadv4);
if(telnet_listenthreadv6 != 0u)
pthread_cancel(telnet_listenthreadv6);
if(socket_listenthread != 0u)
pthread_cancel(socket_listenthread);
if(DBthread != 0u)
pthread_cancel(DBthread);
if(GCthread != 0u)
pthread_cancel(GCthread);
if(DNSclientthread != 0u)
pthread_cancel(DNSclientthread);
pthread_cancel(telnet_listenthreadv4);
pthread_cancel(telnet_listenthreadv6);
pthread_cancel(socket_listenthread);
pthread_cancel(DBthread);
pthread_cancel(GCthread);
pthread_cancel(DNSclientthread);
// Close gravity database connection
gravityDB_close();
+6
View File
@@ -17,6 +17,8 @@
#include "gravity-db.h"
// cli_mode
#include "../args.h"
// cleanup()
#include "../daemon.h"
static const char *message_types[MAX_MESSAGE] =
{ "REGEX", "SUBNET", "HOSTNAME", "DNSMASQ_CONFIG" };
@@ -271,4 +273,8 @@ void logg_fatal_dnsmasq_message(const char *message)
// Log to database (we have to open the database at this point)
dbopen();
add_message(DNSMASQ_CONFIG_MESSAGE, message, 0);
// FTL will dies after this point, so we should make sure to clean up
// behind ourselves
cleanup(EXIT_FAILURE);
}
+6 -6
View File
@@ -1740,12 +1740,12 @@ static void save_reply_type(const unsigned int flags, const union all_addr *addr
query->response;
}
pthread_t telnet_listenthreadv4 = 0u;
pthread_t telnet_listenthreadv6 = 0u;
pthread_t socket_listenthread = 0u;
pthread_t DBthread = 0u;
pthread_t GCthread = 0u;
pthread_t DNSclientthread = 0u;
pthread_t telnet_listenthreadv4;
pthread_t telnet_listenthreadv6;
pthread_t socket_listenthread;
pthread_t DBthread;
pthread_t GCthread;
pthread_t DNSclientthread;
void FTL_fork_and_bind_sockets(struct passwd *ent_pw)
{