From: Timo Sirainen Date: Thu, 16 Apr 2009 23:14:23 +0000 (-0400) Subject: Added imap_idle_notify_interval setting. X-Git-Tag: 2.0.alpha1~929 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=e40840f74672872db99d29b4eb5511869e238004;p=thirdparty%2Fdovecot%2Fcore.git Added imap_idle_notify_interval setting. --HG-- branch : HEAD --- diff --git a/dovecot-example.conf b/dovecot-example.conf index 293154b195..b1b6366c1e 100644 --- a/dovecot-example.conf +++ b/dovecot-example.conf @@ -576,6 +576,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 # currently: name, version, os, os-version, support-url, support-email. diff --git a/src/imap/cmd-idle.c b/src/imap/cmd-idle.c index c8982c197f..c930041d92 100644 --- a/src/imap/cmd-idle.c +++ b/src/imap/cmd-idle.c @@ -10,10 +10,6 @@ #include -/* 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 client_command_context *cmd) { 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 client_command_context *cmd) } 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_context *cmd) 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 --git a/src/imap/imap-settings.c b/src/imap/imap-settings.c index 755f820665..3710f85cf9 100644 --- a/src/imap/imap-settings.c +++ b/src/imap/imap-settings.c @@ -22,6 +22,7 @@ static struct setting_define imap_setting_defines[] = { 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_settings = { 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 --git a/src/imap/imap-settings.h b/src/imap/imap-settings.h index ac1ba0fac5..229c71cacf 100644 --- a/src/imap/imap-settings.h +++ b/src/imap/imap-settings.h @@ -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;