dovecot-1.2: Added imap_idle_notify_interval setting.

dovecot at dovecot.org dovecot at dovecot.org
Fri Apr 17 02:14:30 EEST 2009


details:   http://hg.dovecot.org/dovecot-1.2/rev/8de5b2a19a08
changeset: 8955:8de5b2a19a08
user:      Timo Sirainen <tss at iki.fi>
date:      Thu Apr 16 19:11:32 2009 -0400
description:
Added imap_idle_notify_interval setting.

diffstat:

6 files changed, 21 insertions(+), 3 deletions(-)
dovecot-example.conf              |    4 ++++
src/imap/cmd-idle.c               |   15 ++++++++++++---
src/master/mail-process.c         |    2 ++
src/master/master-settings-defs.c |    1 +
src/master/master-settings.c      |    1 +
src/master/master-settings.h      |    1 +

diffs (105 lines):

diff -r 91da114598f1 -r 8de5b2a19a08 dovecot-example.conf
--- a/dovecot-example.conf	Thu Apr 16 18:50:56 2009 -0400
+++ b/dovecot-example.conf	Thu Apr 16 19:11:32 2009 -0400
@@ -571,6 +571,10 @@ protocol imap {
 
   # Override the IMAP CAPABILITY response.
   #imap_capability = 
+
+  # How many seconds to wait between "OK Still here" notifications when
+  # client is IDLEing.
+  #imap_idle_notify_interval = 120
 
   # ID field names and values to send to clients. Using * as the value makes
   # Dovecot use the default value. The following fields have default values
diff -r 91da114598f1 -r 8de5b2a19a08 src/imap/cmd-idle.c
--- a/src/imap/cmd-idle.c	Thu Apr 16 18:50:56 2009 -0400
+++ b/src/imap/cmd-idle.c	Thu Apr 16 19:11:32 2009 -0400
@@ -12,7 +12,7 @@
 #define DEFAULT_IDLE_CHECK_INTERVAL 30
 /* Send some noice to client every few minutes to avoid NATs and stateful
    firewalls from closing the connection */
-#define KEEPALIVE_TIMEOUT (2*60)
+#define DEFAULT_IMAP_IDLE_NOTIFY_INTERVAL (2*60)
 
 struct cmd_idle_context {
 	struct client *client;
@@ -134,6 +134,7 @@ static bool cmd_idle_continue(struct cli
 {
 	struct client *client = cmd->client;
 	struct cmd_idle_context *ctx = cmd->context;
+	uoff_t orig_offset = client->output->offset;
 
 	if (cmd->cancel) {
 		idle_finish(ctx, FALSE, FALSE);
@@ -164,6 +165,9 @@ static bool cmd_idle_continue(struct cli
 		}
 		ctx->sync_ctx = NULL;
 	}
+	if (client->output->offset != orig_offset &&
+	    ctx->keepalive_to != NULL)
+		timeout_reset(ctx->keepalive_to);
 
 	if (ctx->sync_pending) {
 		/* more changes occurred while we were sending changes to
@@ -204,8 +208,13 @@ bool cmd_idle(struct client_command_cont
 	ctx->cmd = cmd;
 	ctx->client = client;
 
-	ctx->keepalive_to = timeout_add(KEEPALIVE_TIMEOUT * 1000,
-					keepalive_timeout, ctx);
+	str = getenv("IMAP_IDLE_NOTIFY_INTERVAL");
+	interval = str != NULL ?
+		(unsigned int)strtoul(str, NULL, 10) :
+		DEFAULT_IMAP_IDLE_NOTIFY_INTERVAL;
+	ctx->keepalive_to = interval == 0 ? NULL :
+		timeout_add(interval * 1000,
+			    keepalive_timeout, ctx);
 
 	str = getenv("MAILBOX_IDLE_CHECK_INTERVAL");
 	interval = str == NULL ? 0 : (unsigned int)strtoul(str, NULL, 10);
diff -r 91da114598f1 -r 8de5b2a19a08 src/master/mail-process.c
--- a/src/master/mail-process.c	Thu Apr 16 18:50:56 2009 -0400
+++ b/src/master/mail-process.c	Thu Apr 16 19:11:32 2009 -0400
@@ -327,6 +327,8 @@ mail_process_set_environment(struct sett
 				    set->imap_logout_format, NULL));
 		env_put(t_strconcat("IMAP_ID_SEND=", set->imap_id_send, NULL));
 		env_put(t_strconcat("IMAP_ID_LOG=", set->imap_id_log, NULL));
+		env_put(t_strdup_printf("IMAP_IDLE_NOTIFY_INTERVAL=%u",
+					set->imap_idle_notify_interval));
 	}
 	if (set->protocol == MAIL_PROTOCOL_POP3) {
 		env_put(t_strconcat("POP3_CLIENT_WORKAROUNDS=",
diff -r 91da114598f1 -r 8de5b2a19a08 src/master/master-settings-defs.c
--- a/src/master/master-settings-defs.c	Thu Apr 16 18:50:56 2009 -0400
+++ b/src/master/master-settings-defs.c	Thu Apr 16 19:11:32 2009 -0400
@@ -115,6 +115,7 @@ static struct setting_def setting_defs[]
 	DEF_STR(imap_logout_format),
 	DEF_STR(imap_id_send),
 	DEF_STR(imap_id_log),
+	DEF_INT(imap_idle_notify_interval),
 
 	/* pop3 */
 	DEF_BOOL(pop3_no_flag_updates),
diff -r 91da114598f1 -r 8de5b2a19a08 src/master/master-settings.c
--- a/src/master/master-settings.c	Thu Apr 16 18:50:56 2009 -0400
+++ b/src/master/master-settings.c	Thu Apr 16 19:11:32 2009 -0400
@@ -281,6 +281,7 @@ struct settings default_settings = {
 	MEMBER(imap_logout_format) "bytes=%i/%o",
 	MEMBER(imap_id_send) "",
 	MEMBER(imap_id_log) "",
+	MEMBER(imap_idle_notify_interval) 120,
 
 	/* pop3 */
 	MEMBER(pop3_no_flag_updates) FALSE,
diff -r 91da114598f1 -r 8de5b2a19a08 src/master/master-settings.h
--- a/src/master/master-settings.h	Thu Apr 16 18:50:56 2009 -0400
+++ b/src/master/master-settings.h	Thu Apr 16 19:11:32 2009 -0400
@@ -127,6 +127,7 @@ struct settings {
 	const char *imap_logout_format;
 	const char *imap_id_send;
 	const char *imap_id_log;
+	unsigned int imap_idle_notify_interval;
 
 	/* pop3 */
 	bool pop3_no_flag_updates;


More information about the dovecot-cvs mailing list