dovecot-2.1: stats: Make sure unfinished commands get freed when...

dovecot at dovecot.org dovecot at dovecot.org
Fri Sep 23 16:07:39 EEST 2011


details:   http://hg.dovecot.org/dovecot-2.1/rev/67a545272b3f
changeset: 13552:67a545272b3f
user:      Timo Sirainen <tss at iki.fi>
date:      Fri Sep 23 16:07:29 2011 +0300
description:
stats: Make sure unfinished commands get freed when their session disconnects.

diffstat:

 src/stats/mail-command.c |  14 +++++++++++---
 1 files changed, 11 insertions(+), 3 deletions(-)

diffs (24 lines):

diff -r df74f0052707 -r 67a545272b3f src/stats/mail-command.c
--- 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)


More information about the dovecot-cvs mailing list