Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reload blocking mode independently of incoming queries #1310

Merged
merged 2 commits into from
Mar 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions src/database/database-thread.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
#include "aliasclients.h"
// Eventqueue routines
#include "../events.h"
// check_blocking_status()
#include "../setupVars.h"

#define DBOPEN_OR_AGAIN() { db = dbopen(false); if(db == NULL) { thread_sleepms(DB, 5000); continue; } }
#define BREAK_IF_KILLED() { if(killed) break; }
Expand Down Expand Up @@ -116,8 +118,14 @@ void *DB_thread(void *val)

BREAK_IF_KILLED();

// Sleep 1 sec
thread_sleepms(DB, 1000);
// Inspect setupVars.conf to see if Pi-hole blocking is enabled
if(get_and_clear_event(RELOAD_BLOCKINGSTATUS))
check_blocking_status();

BREAK_IF_KILLED();

// Sleep 0.1 sec
thread_sleepms(DB, 100);
yubiuser marked this conversation as resolved.
Show resolved Hide resolved
}

logg("Terminating database thread");
Expand Down
10 changes: 2 additions & 8 deletions src/dnsmasq_interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -1230,12 +1230,6 @@ static bool special_domain(const queriesData *query, const char *domain)

static bool _FTL_check_blocking(int queryID, int domainID, int clientID, const char* file, const int line)
{
if(get_and_clear_event(RELOAD_BLOCKINGMODE))
{
// Inspect setupVars.conf to see if Pi-hole blocking is enabled
check_blocking_status();
}

// Only check blocking conditions when global blocking is enabled
if(blockingstatus == BLOCKING_DISABLED)
{
Expand Down Expand Up @@ -1773,9 +1767,9 @@ void FTL_dnsmasq_reload(void)
logg("Reloading DNS cache");
lock_shm();

// Request reload the privacy level and blocking mode
// Request reload the privacy level and blocking status
set_event(RELOAD_PRIVACY_LEVEL);
set_event(RELOAD_BLOCKINGMODE);
set_event(RELOAD_BLOCKINGSTATUS);
yubiuser marked this conversation as resolved.
Show resolved Hide resolved

// Reread pihole-FTL.conf to see which blocking mode the user wants to use
// It is possible to change the blocking mode here as we anyhow clear the
Expand Down
2 changes: 1 addition & 1 deletion src/enums.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ enum events {
RERESOLVE_HOSTNAMES_FORCE,
REIMPORT_ALIASCLIENTS,
PARSE_NEIGHBOR_CACHE,
RELOAD_BLOCKINGMODE,
RELOAD_BLOCKINGSTATUS,
EVENTS_MAX
} __attribute__ ((packed));

Expand Down
4 changes: 2 additions & 2 deletions src/events.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ static const char *eventtext(const enum events event)
return "PARSE_NEIGHBOR_CACHE";
case RESOLVE_NEW_HOSTNAMES:
return "RESOLVE_NEW_HOSTNAMES";
case RELOAD_BLOCKINGMODE:
return "RELOAD_BLOCKINGMODE";
case RELOAD_BLOCKINGSTATUS:
return "RELOAD_BLOCKINGSTATUS";
case EVENTS_MAX: // fall through
default:
return "UNKNOWN";
Expand Down
4 changes: 2 additions & 2 deletions src/signals.c
Original file line number Diff line number Diff line change
Expand Up @@ -292,8 +292,8 @@ static void SIGRT_handler(int signum, siginfo_t *si, void *unused)
// Reload the privacy level in case the user changed it
set_event(RELOAD_PRIVACY_LEVEL);

// Reload blocking mode
set_event(RELOAD_BLOCKINGMODE);
// Reload blocking status
set_event(RELOAD_BLOCKINGSTATUS);
}
else if(rtsig == 2)
{
Expand Down