]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
Added imap_idle_notify_interval setting.
authorTimo Sirainen <tss@iki.fi>
Thu, 16 Apr 2009 23:14:23 +0000 (19:14 -0400)
committerTimo Sirainen <tss@iki.fi>
Thu, 16 Apr 2009 23:14:23 +0000 (19:14 -0400)
--HG--
branch : HEAD

dovecot-example.conf
src/imap/cmd-idle.c
src/imap/imap-settings.c
src/imap/imap-settings.h

index 293154b195da8ddf1d80b8b85ae914f1a16139c3..b1b6366c1ebc037d8c737d8d228ab8efe16b19bc 100644 (file)
@@ -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.
index c8982c197f80350b88f4ebfc583d9f486bbd3849..c930041d92a274b337b48d14e1199345af27c44c 100644 (file)
 
 #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 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;
index 755f82066520caa9059573cd7c10bf6281648538..3710f85cf974b4acc02fab7cfeb7b492e7cdfa84 100644 (file)
@@ -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",
index ac1ba0fac56cee952e520b07959702f7705af069..229c71cacf44f8f69a6654e23d940f8302e74e02 100644 (file)
@@ -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;