dovecot-2.1: stats: Mail commands were sorted in wrong order, so...

dovecot at dovecot.org dovecot at dovecot.org
Tue Sep 27 18:48:56 EEST 2011


details:   http://hg.dovecot.org/dovecot-2.1/rev/e62621d28591
changeset: 13561:e62621d28591
user:      Timo Sirainen <tss at iki.fi>
date:      Tue Sep 27 18:57:14 2011 +0300
description:
stats: Mail commands were sorted in wrong order, so they were never removed from memory.

diffstat:

 src/stats/client-export.c |   2 +-
 src/stats/mail-command.c  |  23 +++++++++++++----------
 src/stats/mail-command.h  |   3 ++-
 3 files changed, 16 insertions(+), 12 deletions(-)

diffs (99 lines):

diff -r 69826dc7a959 -r e62621d28591 src/stats/client-export.c
--- a/src/stats/client-export.c	Tue Sep 27 18:14:32 2011 +0300
+++ b/src/stats/client-export.c	Tue Sep 27 18:57:14 2011 +0300
@@ -546,7 +546,7 @@
 
 	switch (cmd->level) {
 	case MAIL_EXPORT_LEVEL_COMMAND:
-		client->mail_cmd_iter = stable_mail_commands;
+		client->mail_cmd_iter = stable_mail_commands_head;
 		if (client->mail_cmd_iter == NULL)
 			return FALSE;
 		mail_command_ref(client->mail_cmd_iter);
diff -r 69826dc7a959 -r e62621d28591 src/stats/mail-command.c
--- a/src/stats/mail-command.c	Tue Sep 27 18:14:32 2011 +0300
+++ b/src/stats/mail-command.c	Tue Sep 27 18:57:14 2011 +0300
@@ -10,7 +10,8 @@
 #include "mail-command.h"
 
 /* commands are sorted by their last_update timestamp, oldest first */
-struct mail_command *stable_mail_commands;
+struct mail_command *stable_mail_commands_head;
+struct mail_command *stable_mail_commands_tail;
 
 static size_t mail_command_memsize(const struct mail_command *cmd)
 {
@@ -49,7 +50,8 @@
 	cmd->args = i_strdup(args);
 	cmd->last_update = ioloop_timeval;
 
-	DLLIST_PREPEND_FULL(&stable_mail_commands, cmd,
+	DLLIST2_APPEND_FULL(&stable_mail_commands_head,
+			    &stable_mail_commands_tail, cmd,
 			    stable_prev, stable_next);
 	DLLIST_PREPEND_FULL(&session->commands, cmd,
 			    session_prev, session_next);
@@ -64,7 +66,8 @@
 
 	global_memory_free(mail_command_memsize(cmd));
 
-	DLLIST_REMOVE_FULL(&stable_mail_commands, cmd,
+	DLLIST2_REMOVE_FULL(&stable_mail_commands_head,
+			    &stable_mail_commands_tail, cmd,
 			    stable_prev, stable_next);
 	DLLIST_REMOVE_FULL(&cmd->session->commands, cmd,
 			   session_prev, session_next);
@@ -155,8 +158,8 @@
 {
 	unsigned int diff;
 
-	while (stable_mail_commands != NULL) {
-		struct mail_command *cmd = stable_mail_commands;
+	while (stable_mail_commands_head != NULL) {
+		struct mail_command *cmd = stable_mail_commands_head;
 
 		if (cmd->refcount == 0)
 			i_assert(cmd->id == 0);
@@ -166,12 +169,12 @@
 		} else {
 			break;
 		}
-		mail_command_free(stable_mail_commands);
+		mail_command_free(stable_mail_commands_head);
 
 		if (global_used_memory < stats_settings->memory_limit)
 			break;
 
-		diff = ioloop_time - stable_mail_commands->last_update.tv_sec;
+		diff = ioloop_time - stable_mail_commands_head->last_update.tv_sec;
 		if (diff < stats_settings->command_min_time)
 			break;
 	}
@@ -183,11 +186,11 @@
 
 void mail_commands_deinit(void)
 {
-	while (stable_mail_commands != NULL) {
-		struct mail_command *cmd = stable_mail_commands;
+	while (stable_mail_commands_head != NULL) {
+		struct mail_command *cmd = stable_mail_commands_head;
 
 		if (cmd->id != 0)
 			mail_command_unref(&cmd);
-		mail_command_free(stable_mail_commands);
+		mail_command_free(stable_mail_commands_head);
 	}
 }
diff -r 69826dc7a959 -r e62621d28591 src/stats/mail-command.h
--- a/src/stats/mail-command.h	Tue Sep 27 18:14:32 2011 +0300
+++ b/src/stats/mail-command.h	Tue Sep 27 18:57:14 2011 +0300
@@ -3,7 +3,8 @@
 
 struct mail_command;
 
-extern struct mail_command *stable_mail_commands;
+extern struct mail_command *stable_mail_commands_head;
+extern struct mail_command *stable_mail_commands_tail;
 
 int mail_command_update_parse(const char *const *args, const char **error_r);
 


More information about the dovecot-cvs mailing list