Mercurial > dovecot > core-2.2
changeset 13561:e62621d28591
stats: Mail commands were sorted in wrong order, so they were never removed from memory.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Tue, 27 Sep 2011 18:57:14 +0300 |
parents | 69826dc7a959 |
children | 64d3f748a612 |
files | src/stats/client-export.c src/stats/mail-command.c src/stats/mail-command.h |
diffstat | 3 files changed, 16 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- 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);
--- 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); } }
--- 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);