From 6e03a57507f55a504f706b15b96c8cb35e5f5210 Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Fri, 23 Sep 2011 16:07:29 +0300 Subject: [PATCH] stats: Make sure unfinished commands get freed when their session disconnects. --- src/stats/mail-command.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/stats/mail-command.c b/src/stats/mail-command.c index cab7a42fa6..440b50586c 100644 --- a/src/stats/mail-command.c +++ b/src/stats/mail-command.c @@ -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) -- 2.47.3