From: Timo Sirainen Date: Wed, 21 Jan 2009 20:48:51 +0000 (-0500) Subject: Sending SIGUSR2 to dovecot-auth now also logs statistics about cache inserts. X-Git-Tag: 1.2.beta1~73 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=20df5a94b36be8e6c2d0e481973cab6715c61bb8;p=thirdparty%2Fdovecot%2Fcore.git Sending SIGUSR2 to dovecot-auth now also logs statistics about cache inserts. --HG-- branch : HEAD --- diff --git a/src/auth/auth-cache.c b/src/auth/auth-cache.c index b90b91682c..cf7a647124 100644 --- a/src/auth/auth-cache.c +++ b/src/auth/auth-cache.c @@ -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 signo ATTR_UNUSED, void *context) 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, struct auth_request *request, cache->size_left -= alloc_size; hash_table_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,