changeset 2855:0e0682b3167b HEAD

SIGHUP now clears cache.
author Timo Sirainen <tss@iki.fi>
date Sat, 06 Nov 2004 22:23:13 +0200
parents e0db9324e799
children 76a4ecb71b86
files src/auth/auth-cache.c
diffstat 1 files changed, 12 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/auth/auth-cache.c	Sat Nov 06 22:22:59 2004 +0200
+++ b/src/auth/auth-cache.c	Sat Nov 06 22:23:13 2004 +0200
@@ -1,6 +1,7 @@
 /* Copyright (C) 2004 Timo Sirainen */
 
 #include "common.h"
+#include "lib-signals.h"
 #include "hash.h"
 #include "str.h"
 #include "strescape.h"
@@ -23,6 +24,7 @@
 
 	size_t size_left;
 	unsigned int ttl_secs;
+	unsigned int hup_count;
 };
 
 char *auth_cache_parse_key(const char *query)
@@ -90,6 +92,7 @@
 	struct auth_cache *cache;
 
 	cache = i_new(struct auth_cache, 1);
+	cache->hup_count = lib_signal_hup_count;
 	cache->hash = hash_create(default_pool, default_pool, 0, str_hash,
 				  (hash_cmp_callback_t *)strcmp);
 	cache->size_left = max_size;
@@ -109,6 +112,8 @@
 	while (cache->tail != NULL)
 		auth_cache_node_destroy(cache, cache->tail);
 	hash_clear(cache->hash, FALSE);
+
+	cache->hup_count = lib_signal_hup_count;
 }
 
 const char *auth_cache_lookup(struct auth_cache *cache,
@@ -116,7 +121,13 @@
 			      const char *key)
 {
 	string_t *str;
-        struct cache_node *node;
+	struct cache_node *node;
+
+	if (cache->hup_count != lib_signal_hup_count) {
+		/* SIGHUP received - clear cache */
+		auth_cache_clear(cache);
+		return NULL;
+	}
 
 	str = t_str_new(256);
 	var_expand(str, key,