mirror of
https://github.com/pi-hole/FTL.git
synced 2024-10-26 16:52:18 +02:00
Improve performance significantly. We store if (and if: why) a certain domain was blocked for any requesting client and can immediately reply similarly if the same client requests the same domain again. This reduces the O(N^3) problem (number of queries * number of domains * number of clients) to a O(N^2) problem (domains * clients). Note that this state of the code still lacks a possibility to reset when entries in the database have changed. For this, we still have to send either SIGHUP (drawback: clears the cache) or define a new signal for it.
Signed-off-by: DL6ER <dl6er@dl6er.de>
This commit is contained in:
+9
-3
@@ -121,12 +121,18 @@ bool match_regex(const char *input, const clientsData *client, const unsigned ch
|
||||
static void free_regex(void)
|
||||
{
|
||||
// Reset cached regex results
|
||||
for(int i = 0; i < counters->domains; i++) {
|
||||
for(int i = 0u; i < counters->domains; i++)
|
||||
{
|
||||
// Get domain pointer
|
||||
domainsData *domain = getDomain(i, true);
|
||||
if(domain == NULL)
|
||||
continue;
|
||||
|
||||
// Reset regexmatch to unknown
|
||||
domain->regexmatch = REGEX_UNKNOWN;
|
||||
// Reset blocking status of domain for all clients to unknown
|
||||
for(int clientID = 0u; clientID < counters->clients; clientID++)
|
||||
{
|
||||
domain->clientstatus->set(domain->clientstatus, clientID, UNKNOWN_BLOCKED);
|
||||
}
|
||||
}
|
||||
|
||||
// Return early if we don't use any regex filters
|
||||
|
||||
Reference in New Issue
Block a user