]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
stats: Make sure unfinished commands get freed when their session disconnects.
authorTimo Sirainen <tss@iki.fi>
Fri, 23 Sep 2011 13:07:29 +0000 (16:07 +0300)
committerTimo Sirainen <tss@iki.fi>
Fri, 23 Sep 2011 13:07:29 +0000 (16:07 +0300)
src/stats/mail-command.c

index cab7a42fa68b063acc8d6133183a3d478a28eca7..440b50586ce741d112cf73c39939af313e901dfc 100644 (file)
@@ -153,9 +153,17 @@ int mail_command_update_parse(const char *const *args, const char **error_r)
 
 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)