[dovecot-cvs] dovecot/src/auth auth-cache.c,1.10,1.11

cras at dovecot.org cras at dovecot.org
Wed Jun 8 18:45:44 EEST 2005


Update of /var/lib/cvs/dovecot/src/auth
In directory talvi:/tmp/cvs-serv1229

Modified Files:
	auth-cache.c 
Log Message:
Count cache hits and misses, report them on SIGUSR2.



Index: auth-cache.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/auth-cache.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- auth-cache.c	5 Mar 2005 11:57:29 -0000	1.10
+++ auth-cache.c	8 Jun 2005 15:45:41 -0000	1.11
@@ -24,7 +24,9 @@
 
 	size_t size_left;
 	unsigned int ttl_secs;
-	unsigned int hup_count;
+	unsigned int hup_count, usr2_count;
+
+	unsigned int hit_count, miss_count;
 };
 
 char *auth_cache_parse_key(const char *query)
@@ -130,6 +132,7 @@
 {
 	string_t *str;
 	struct cache_node *node;
+	unsigned int total_count;
 
 	*expired_r = FALSE;
 
@@ -140,13 +143,28 @@
 		return NULL;
 	}
 
+	if (cache->usr2_count != lib_signal_usr2_count) {
+		cache->usr2_count = lib_signal_usr2_count;
+
+		total_count = cache->hit_count + cache->miss_count;
+		i_info("Authentication cache hits %u/%u (%u%%)",
+		       cache->hit_count, total_count,
+		       cache->hit_count * 100 / total_count);
+
+		/* reset hit counter */
+		cache->hit_count = cache->miss_count = 0;
+	}
+
 	str = t_str_new(256);
 	var_expand(str, key,
 		   auth_request_get_var_expand_table(request, str_escape));
 
 	node = hash_lookup(cache->hash, str_c(str));
-	if (node == NULL)
+	if (node == NULL) {
+		cache->miss_count++;
 		return NULL;
+	}
+	cache->hit_count++;
 
 	if (node->created < time(NULL) - (time_t)cache->ttl_secs) {
 		/* TTL expired */



More information about the dovecot-cvs mailing list