dovecot-1.1: Sending SIGUSR2 to dovecot-auth now also logs stati...

dovecot at dovecot.org dovecot at dovecot.org
Wed Jan 21 22:48:57 EET 2009


details:   http://hg.dovecot.org/dovecot-1.1/rev/9d73ef69e0f2
changeset: 8115:9d73ef69e0f2
user:      Timo Sirainen <tss at iki.fi>
date:      Wed Jan 21 15:48:51 2009 -0500
description:
Sending SIGUSR2 to dovecot-auth now also logs statistics about cache inserts.

diffstat:

1 file changed, 18 insertions(+), 1 deletion(-)
src/auth/auth-cache.c |   19 ++++++++++++++++++-

diffs (44 lines):

diff -r 3bf99b87d50b -r 9d73ef69e0f2 src/auth/auth-cache.c
--- a/src/auth/auth-cache.c	Wed Jan 21 12:39:18 2009 -0500
+++ b/src/auth/auth-cache.c	Wed Jan 21 15:48:51 2009 -0500
@@ -19,6 +19,8 @@ struct auth_cache {
 	unsigned int ttl_secs, neg_ttl_secs;
 
 	unsigned int hit_count, miss_count;
+	unsigned int pos_entries, neg_entries;
+	unsigned long long pos_size, neg_size;
 };
 
 char *auth_cache_parse_key(pool_t pool, const char *query)
@@ -108,8 +110,15 @@ static void sig_auth_cache_stats(int sig
 	       cache->hit_count, total_count,
 	       total_count == 0 ? 100 : (cache->hit_count * 100 / total_count));
 
-	/* reset hit counter */
+	i_info("Authentication cache inserts: "
+	       "positive: %u %lluB, negative: %u %lluB",
+	       cache->pos_entries, cache->pos_size,
+	       cache->neg_entries, cache->neg_size);
+
+	/* reset counters */
 	cache->hit_count = cache->miss_count = 0;
+	cache->pos_entries = cache->neg_entries = 0;
+	cache->pos_size = cache->neg_size = 0;
 }
 
 struct auth_cache *auth_cache_new(size_t max_size, unsigned int ttl_secs,
@@ -249,6 +258,14 @@ void auth_cache_insert(struct auth_cache
 
 	cache->size_left -= alloc_size;
 	hash_insert(cache->hash, node->data, node);
+
+	if (*value != '\0') {
+		cache->pos_entries++;
+		cache->pos_size += alloc_size;
+	} else {
+		cache->neg_entries++;
+		cache->neg_size += alloc_size;
+	}
 }
 
 void auth_cache_remove(struct auth_cache *cache,


More information about the dovecot-cvs mailing list