changeset 13552:67a545272b3f

stats: Make sure unfinished commands get freed when their session disconnects.
author Timo Sirainen <tss@iki.fi>
date Fri, 23 Sep 2011 16:07:29 +0300
parents df74f0052707
children af13ef62d083
files src/stats/mail-command.c
diffstat 1 files changed, 11 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/stats/mail-command.c	Fri Sep 23 15:01:57 2011 +0300
+++ b/src/stats/mail-command.c	Fri Sep 23 16:07:29 2011 +0300
@@ -153,9 +153,17 @@
 
 void mail_commands_free_memory(void)
 {
-	while (stable_mail_commands != NULL &&
-	       stable_mail_commands->refcount == 0) {
-		i_assert(stable_mail_commands->id == 0);
+	while (stable_mail_commands != NULL) {
+		struct mail_command *cmd = stable_mail_commands;
+
+		if (cmd->refcount == 0)
+			i_assert(cmd->id == 0);
+		else if (cmd->refcount == 1 && cmd->session->disconnected) {
+			/* session was probably lost */
+			mail_command_unref(&cmd);
+		} else {
+			break;
+		}
 		mail_command_free(stable_mail_commands);
 
 		if (global_used_memory < stats_settings->memory_limit)