changeset 8955:8de5b2a19a08 HEAD

Added imap_idle_notify_interval setting.
author Timo Sirainen <tss@iki.fi>
date Thu, 16 Apr 2009 19:11:32 -0400
parents 91da114598f1
children 9619fbd698d5
files dovecot-example.conf src/imap/cmd-idle.c src/master/mail-process.c src/master/master-settings-defs.c src/master/master-settings.c src/master/master-settings.h
diffstat 6 files changed, 21 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/dovecot-example.conf	Thu Apr 16 18:50:56 2009 -0400
+++ b/dovecot-example.conf	Thu Apr 16 19:11:32 2009 -0400
@@ -572,6 +572,10 @@
   # 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
   # currently: name, version, os, os-version, support-url, support-email.
--- 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 @@
 {
 	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 @@
 		}
 		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 @@
 	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);
--- 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 @@
 				    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=",
--- 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 @@
 	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),
--- 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 @@
 	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,
--- 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 @@
 	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;