dovecot-1.3: Added imap_idle_notify_interval setting.

dovecot at dovecot.org dovecot at dovecot.org
Fri Apr 17 02:48:53 EEST 2009


details:   http://hg.dovecot.org/dovecot-1.3/rev/edcafb3efbbf
changeset: 9123:edcafb3efbbf
user:      Timo Sirainen <tss at iki.fi>
date:      Thu Apr 16 19:14:23 2009 -0400
description:
Added imap_idle_notify_interval setting.

diffstat:

4 files changed, 14 insertions(+), 6 deletions(-)
dovecot-example.conf     |    4 ++++
src/imap/cmd-idle.c      |   13 +++++++------
src/imap/imap-settings.c |    2 ++
src/imap/imap-settings.h |    1 +

diffs (88 lines):

diff -r d33915e5da10 -r edcafb3efbbf dovecot-example.conf
--- a/dovecot-example.conf	Thu Apr 16 18:50:56 2009 -0400
+++ b/dovecot-example.conf	Thu Apr 16 19:14:23 2009 -0400
@@ -575,6 +575,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 d33915e5da10 -r edcafb3efbbf 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: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 @@ 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 +161,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
@@ -202,8 +202,9 @@ bool cmd_idle(struct client_command_cont
 	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;
diff -r d33915e5da10 -r edcafb3efbbf src/imap/imap-settings.c
--- 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 @@ static struct setting_define imap_settin
 	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 @@ static struct imap_settings imap_default
 	   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",
diff -r d33915e5da10 -r edcafb3efbbf src/imap/imap-settings.h
--- 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 @@ struct imap_settings {
 
 	/* 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;


More information about the dovecot-cvs mailing list