summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaweł Redman <pawel.redman@gmail.com>2017-04-06 21:43:20 +0200
committerPaweł Redman <pawel.redman@gmail.com>2017-04-06 21:43:20 +0200
commit10a0bd03c08dd6b6023d26dd090352620c5cbd6e (patch)
tree20980b358f0b5519241ef67dfbb30466ca18e0aa
parent162787fbbb33c3cae6cf6e4d5b8fadc4a51cff8f (diff)
Invalidate cached results on reloads.
-rw-r--r--src/database.c14
-rw-r--r--src/lists.c4
-rw-r--r--src/shared.h1
3 files changed, 17 insertions, 2 deletions
diff --git a/src/database.c b/src/database.c
index 7e4de95..886c9a4 100644
--- a/src/database.c
+++ b/src/database.c
@@ -93,3 +93,17 @@ void db_destroy(void)
pthread_mutex_unlock(&database_mutex);
}
+
+void db_invalidate_cached_results(void)
+{
+ size_t i;
+ db_entry *entry;
+
+ pthread_mutex_lock(&database_mutex);
+
+ for (i = 0; i < HASH_MAX; i++)
+ eli_for(entry, database[i], ht_chain)
+ entry->cached_result_valid = false;
+
+ pthread_mutex_unlock(&database_mutex);
+}
diff --git a/src/lists.c b/src/lists.c
index 98ba866..8eb0d5e 100644
--- a/src/lists.c
+++ b/src/lists.c
@@ -151,9 +151,9 @@ int lists_reload(const char *file)
ret = lists_load(file, 0);
if (!ret)
lists_destroy();
- pthread_mutex_unlock(&entry_list_mutex);
- // FIXME: invalidate all cached results
+ db_invalidate_cached_results();
+ pthread_mutex_unlock(&entry_list_mutex);
return ret;
}
diff --git a/src/shared.h b/src/shared.h
index 13fd791..187edcc 100644
--- a/src/shared.h
+++ b/src/shared.h
@@ -87,6 +87,7 @@ typedef struct {
db_entry *db_find(uint32_t ipv4);
void db_destroy(void);
+void db_invalidate_cached_results(void);
// worker.c