dovecot: Client is now never disconnected in IDLE because it has...
dovecot at dovecot.org
dovecot at dovecot.org
Tue Aug 7 12:10:31 EEST 2007
details: http://hg.dovecot.org/dovecot/rev/da3c8d825f5c
changeset: 6210:da3c8d825f5c
user: Timo Sirainen <tss at iki.fi>
date: Tue Aug 07 12:10:27 2007 +0300
description:
Client is now never disconnected in IDLE because it hasn't sent anything.
Removed outlook-idle workaround because it's no longer needed.
diffstat:
7 files changed, 11 insertions(+), 66 deletions(-)
dovecot-example.conf | 7 -----
src/imap/client.c | 7 -----
src/imap/client.h | 1
src/imap/cmd-idle.c | 57 +++++-------------------------------------
src/imap/common.h | 1
src/imap/main.c | 2 -
src/master/master-settings.c | 2 -
diffs (210 lines):
diff -r 939e0ca61f11 -r da3c8d825f5c dovecot-example.conf
--- a/dovecot-example.conf Tue Aug 07 12:04:09 2007 +0300
+++ b/dovecot-example.conf Tue Aug 07 12:10:27 2007 +0300
@@ -538,11 +538,6 @@ protocol imap {
# may show user "Message no longer in server" errors. Note that OE6 still
# breaks even with this workaround if synchronization is set to
# "Headers Only".
- # outlook-idle:
- # Outlook and Outlook Express never abort IDLE command, so if no mail
- # arrives in half a hour, Dovecot closes the connection. This is still
- # fine, except Outlook doesn't connect back so you don't see if new mail
- # arrives.
# netscape-eoh:
# Netscape 4.x breaks if message headers don't end with the empty "end of
# headers" line. Normally all messages have this, but setting this
@@ -554,7 +549,7 @@ protocol imap {
# but not both. Thunderbird separates these two by forcing server to
# accept '/' suffix in mailbox names in subscriptions list.
# The list is space-separated.
- #imap_client_workarounds = outlook-idle
+ #imap_client_workarounds =
}
##
diff -r 939e0ca61f11 -r da3c8d825f5c src/imap/client.c
--- a/src/imap/client.c Tue Aug 07 12:04:09 2007 +0300
+++ b/src/imap/client.c Tue Aug 07 12:10:27 2007 +0300
@@ -691,12 +691,7 @@ static void idle_timeout(void *context _
if (my_client == NULL)
return;
- /* We mostly want to check last_input here, but if there is a very long
- running command (like copying thousands of messages), we don't want
- to disconnect the client just after the command was finished.
- But any output that IDLE has sent should be ignored. */
- last_change = my_client->idling ? my_client->last_input :
- I_MAX(my_client->last_input, my_client->last_output);
+ last_change = I_MAX(my_client->last_input, my_client->last_output);
idle_time = ioloop_time - last_change;
if (o_stream_get_buffer_used_size(my_client->output) > 0 &&
diff -r 939e0ca61f11 -r da3c8d825f5c src/imap/client.h
--- a/src/imap/client.h Tue Aug 07 12:04:09 2007 +0300
+++ b/src/imap/client.h Tue Aug 07 12:10:27 2007 +0300
@@ -66,7 +66,6 @@ struct client {
unsigned int disconnected:1;
unsigned int destroyed:1;
unsigned int handling_input:1;
- unsigned int idling:1;
unsigned int syncing:1;
unsigned int input_skip_line:1; /* skip all the data until we've
found a new line */
diff -r 939e0ca61f11 -r da3c8d825f5c src/imap/cmd-idle.c
--- a/src/imap/cmd-idle.c Tue Aug 07 12:04:09 2007 +0300
+++ b/src/imap/cmd-idle.c Tue Aug 07 12:10:27 2007 +0300
@@ -19,11 +19,9 @@ struct cmd_idle_context {
struct client_command_context *cmd;
struct imap_sync_context *sync_ctx;
- struct timeout *idle_to, *keepalive_to;
- uint32_t dummy_seq;
+ struct timeout *keepalive_to;
unsigned int manual_cork:1;
- unsigned int idle_timeout:1;
unsigned int sync_pending:1;
};
@@ -34,8 +32,6 @@ idle_finish(struct cmd_idle_context *ctx
{
struct client *client = ctx->client;
- if (ctx->idle_to != NULL)
- timeout_remove(&ctx->idle_to);
if (ctx->keepalive_to != NULL)
timeout_remove(&ctx->keepalive_to);
@@ -45,19 +41,11 @@ idle_finish(struct cmd_idle_context *ctx
}
o_stream_cork(client->output);
-
- if (ctx->dummy_seq != 0) {
- /* outlook idle workaround */
- client_send_line(client,
- t_strdup_printf("* %u EXPUNGE", ctx->dummy_seq));
- }
-
io_remove(&client->io);
if (client->mailbox != NULL)
mailbox_notify_changes_stop(client->mailbox);
- client->idling = FALSE;
if (done_ok)
client_send_tagline(ctx->cmd, "OK Idle completed.");
else
@@ -104,33 +92,6 @@ static void idle_client_input(struct cmd
}
}
-static void idle_send_fake_exists(struct cmd_idle_context *ctx)
-{
- struct client *client = ctx->client;
-
- ctx->dummy_seq = client->messages_count+1;
- client_send_line(client,
- t_strdup_printf("* %u EXISTS", ctx->dummy_seq));
- mailbox_notify_changes_stop(client->mailbox);
-}
-
-static void idle_timeout(struct cmd_idle_context *ctx)
-{
- /* outlook workaround - it hasn't sent anything for a long time and
- we're about to disconnect unless it does something. send a fake
- EXISTS to see if it responds. it's expunged later. */
-
- timeout_remove(&ctx->idle_to);
-
- if (ctx->sync_ctx != NULL) {
- /* we're already syncing.. do this after it's finished */
- ctx->idle_timeout = TRUE;
- return;
- }
-
- idle_send_fake_exists(ctx);
-}
-
static void keepalive_timeout(struct cmd_idle_context *ctx)
{
if (ctx->client->output_lock != NULL) {
@@ -138,6 +99,11 @@ static void keepalive_timeout(struct cmd
return;
}
+ /* Sending this keeps NATs/stateful firewalls alive, and it also
+ updates client->last_output so we don't ever disconnect the
+ client. Sending this output should kill dead connections and there
+ are several clients that really want to IDLE forever (Outlook
+ especially). */
client_send_line(ctx->client, "* OK Still here");
}
@@ -195,10 +161,7 @@ static bool cmd_idle_continue(struct cli
ctx->sync_ctx = NULL;
}
- if (ctx->idle_timeout) {
- /* outlook workaround */
- idle_send_fake_exists(ctx);
- } else if (ctx->sync_pending) {
+ if (ctx->sync_pending) {
/* more changes occurred while we were sending changes to
client */
idle_sync_now(client->mailbox, ctx);
@@ -237,11 +200,6 @@ bool cmd_idle(struct client_command_cont
ctx->cmd = cmd;
ctx->client = client;
- if ((client_workarounds & WORKAROUND_OUTLOOK_IDLE) != 0 &&
- client->mailbox != NULL) {
- ctx->idle_to = timeout_add((CLIENT_IDLE_TIMEOUT - 60) * 1000,
- idle_timeout, ctx);
- }
ctx->keepalive_to = timeout_add(KEEPALIVE_TIMEOUT * 1000,
keepalive_timeout, ctx);
@@ -260,7 +218,6 @@ bool cmd_idle(struct client_command_cont
client->io = io_add(i_stream_get_fd(client->input),
IO_READ, idle_client_input, ctx);
- client->idling = TRUE;
cmd->func = cmd_idle_continue;
cmd->context = ctx;
diff -r 939e0ca61f11 -r da3c8d825f5c src/imap/common.h
--- a/src/imap/common.h Tue Aug 07 12:04:09 2007 +0300
+++ b/src/imap/common.h Tue Aug 07 12:10:27 2007 +0300
@@ -25,7 +25,6 @@
enum client_workarounds {
WORKAROUND_DELAY_NEWMAIL = 0x01,
- WORKAROUND_OUTLOOK_IDLE = 0x02,
WORKAROUND_NETSCAPE_EOH = 0x04,
WORKAROUND_TB_EXTRA_MAILBOX_SEP = 0x08
};
diff -r 939e0ca61f11 -r da3c8d825f5c src/imap/main.c
--- a/src/imap/main.c Tue Aug 07 12:04:09 2007 +0300
+++ b/src/imap/main.c Tue Aug 07 12:10:27 2007 +0300
@@ -32,7 +32,7 @@ struct client_workaround_list {
struct client_workaround_list client_workaround_list[] = {
{ "delay-newmail", WORKAROUND_DELAY_NEWMAIL },
- { "outlook-idle", WORKAROUND_OUTLOOK_IDLE },
+ { "outlook-idle", 0 }, /* only for backwards compatibility */
{ "netscape-eoh", WORKAROUND_NETSCAPE_EOH },
{ "tb-extra-mailbox-sep", WORKAROUND_TB_EXTRA_MAILBOX_SEP },
{ NULL, 0 }
diff -r 939e0ca61f11 -r da3c8d825f5c src/master/master-settings.c
--- a/src/master/master-settings.c Tue Aug 07 12:04:09 2007 +0300
+++ b/src/master/master-settings.c Tue Aug 07 12:10:27 2007 +0300
@@ -269,7 +269,7 @@ struct settings default_settings = {
/* imap */
MEMBER(imap_max_line_length) 65536,
MEMBER(imap_capability) "",
- MEMBER(imap_client_workarounds) "outlook-idle",
+ MEMBER(imap_client_workarounds) "",
MEMBER(imap_logout_format) "bytes=%i/%o",
/* pop3 */
More information about the dovecot-cvs
mailing list