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
-2
@@ -126,8 +126,8 @@ int findDomainID(const char *domainString)
|
||||
domain->blockedcount = 0;
|
||||
// Store domain name - no need to check for NULL here as it doesn't harm
|
||||
domain->domainpos = addstr(domainString);
|
||||
// RegEx needs to be evaluated for this new domain
|
||||
domain->regexmatch = REGEX_UNKNOWN;
|
||||
// Storage for individual client blocking status
|
||||
domain->clientstatus = new_ucharvec(counters->clients);
|
||||
// Increase counter by one
|
||||
counters->domains++;
|
||||
|
||||
@@ -201,6 +201,13 @@ int findClientID(const char *clientIP, const bool count)
|
||||
for(int i = 0; i < OVERTIME_SLOTS; i++)
|
||||
client->overTime[i] = 0;
|
||||
|
||||
// Initialize client-specific domain data
|
||||
for(int domainID = 0; domainID < counters->domains; domainID++)
|
||||
{
|
||||
domainsData *domain = getDomain(domainID, true);
|
||||
domain->clientstatus->append(domain->clientstatus, UNKNOWN_BLOCKED);
|
||||
}
|
||||
|
||||
// Allocate regex substructure
|
||||
allocate_regex_client_enabled(client);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user