dovecot-2.1: stats: Forcibly free command after running for 15 m...
dovecot at dovecot.org
dovecot at dovecot.org
Mon Nov 14 23:26:31 EET 2011
details: http://hg.dovecot.org/dovecot-2.1/rev/1cda9fe6d7fa
changeset: 13692:1cda9fe6d7fa
user: Timo Sirainen <tss at iki.fi>
date: Mon Nov 14 23:15:17 2011 +0200
description:
stats: Forcibly free command after running for 15 minutes without updates.
diffstat:
src/stats/mail-command.c | 13 ++++++++++++-
1 files changed, 12 insertions(+), 1 deletions(-)
diffs (37 lines):
diff -r 4d49122ba42a -r 1cda9fe6d7fa src/stats/mail-command.c
--- a/src/stats/mail-command.c Wed Nov 09 22:58:38 2011 +0200
+++ b/src/stats/mail-command.c Mon Nov 14 23:15:17 2011 +0200
@@ -9,6 +9,8 @@
#include "mail-session.h"
#include "mail-command.h"
+#define MAIL_COMMAND_TIMEOUT_SECS (60*15)
+
/* commands are sorted by their last_update timestamp, oldest first */
struct mail_command *stable_mail_commands_head;
struct mail_command *stable_mail_commands_tail;
@@ -154,6 +156,13 @@
return 0;
}
+static bool mail_command_is_timed_out(struct mail_command *cmd)
+{
+ /* some commands like IDLE can run forever */
+ return ioloop_time - cmd->last_update.tv_sec >
+ MAIL_COMMAND_TIMEOUT_SECS;
+}
+
void mail_commands_free_memory(void)
{
unsigned int diff;
@@ -163,7 +172,9 @@
if (cmd->refcount == 0)
i_assert(cmd->id == 0);
- else if (cmd->refcount == 1 && cmd->session->disconnected) {
+ else if (cmd->refcount == 1 &&
+ (cmd->session->disconnected ||
+ mail_command_is_timed_out(cmd))) {
/* session was probably lost */
mail_command_unref(&cmd);
} else {
More information about the dovecot-cvs
mailing list