changeset 9123:edcafb3efbbf HEAD

Added imap_idle_notify_interval setting.
author Timo Sirainen <tss@iki.fi>
date Thu, 16 Apr 2009 19:14:23 -0400
parents d33915e5da10
children a061db71e166
files dovecot-example.conf src/imap/cmd-idle.c src/imap/imap-settings.c src/imap/imap-settings.h
diffstat 4 files changed, 14 insertions(+), 6 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:14:23 2009 -0400
@@ -576,6 +576,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:14:23 2009 -0400
@@ -10,10 +10,6 @@
 
 #include <stdlib.h>
 
-/* Send some noice to client every few minutes to avoid NATs and stateful
-   firewalls from closing the connection */
-#define KEEPALIVE_TIMEOUT (2*60)
-
 struct cmd_idle_context {
 	struct client *client;
 	struct client_command_context *cmd;
@@ -134,6 +130,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 +161,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
@@ -202,8 +202,9 @@
 	ctx->cmd = cmd;
 	ctx->client = client;
 
-	ctx->keepalive_to = timeout_add(KEEPALIVE_TIMEOUT * 1000,
-					keepalive_timeout, ctx);
+	ctx->keepalive_to = client->set->imap_idle_notify_interval == 0 ? NULL :
+		timeout_add(client->set->imap_idle_notify_interval * 1000,
+			    keepalive_timeout, ctx);
 
 	if (client->mailbox != NULL) {
 		const struct mail_storage_settings *set;
--- a/src/imap/imap-settings.c	Thu Apr 16 18:50:56 2009 -0400
+++ b/src/imap/imap-settings.c	Thu Apr 16 19:14:23 2009 -0400
@@ -22,6 +22,7 @@
 	DEF(SET_BOOL, verbose_proctitle),
 
 	DEF(SET_UINT, imap_max_line_length),
+	DEF(SET_UINT, imap_idle_notify_interval),
 	DEF(SET_STR, imap_capability),
 	DEF(SET_STR, imap_client_workarounds),
 	DEF(SET_STR, imap_logout_format),
@@ -40,6 +41,7 @@
 	   break large message sets to multiple commands, so we're pretty
 	   liberal by default. */
 	MEMBER(imap_max_line_length) 65536,
+	MEMBER(imap_idle_notify_interval) 120,
 	MEMBER(imap_capability) "",
 	MEMBER(imap_client_workarounds) "outlook-idle",
 	MEMBER(imap_logout_format) "bytes=%i/%o",
--- a/src/imap/imap-settings.h	Thu Apr 16 18:50:56 2009 -0400
+++ b/src/imap/imap-settings.h	Thu Apr 16 19:14:23 2009 -0400
@@ -10,6 +10,7 @@
 
 	/* imap: */
 	unsigned int imap_max_line_length;
+	unsigned int imap_idle_notify_interval;
 	const char *imap_capability;
 	const char *imap_client_workarounds;
 	const char *imap_logout_format;