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:
DL6ER
2019-11-22 09:42:06 +01:00
parent 7fd801dbc2
commit faac7005d1
9 changed files with 347 additions and 119 deletions
+9 -3
View File
@@ -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