Mercurial > dovecot > original-hg > dovecot-1.2
changeset 5805:3fd09104fd77 HEAD
Changes sent by IDLE shouldn't affect the client's inactivity timeout
checking.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Wed, 27 Jun 2007 16:38:07 +0300 |
parents | c7f35a9beb0b |
children | 3704fe78f2f9 |
files | src/imap/client.c src/imap/client.h src/imap/cmd-idle.c |
diffstat | 3 files changed, 10 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/src/imap/client.c Wed Jun 27 16:24:50 2007 +0300 +++ b/src/imap/client.c Wed Jun 27 16:38:07 2007 +0300 @@ -650,13 +650,18 @@ static void idle_timeout(void *context __attr_unused__) { - time_t idle_time; + time_t idle_time, last_change; if (my_client == NULL) return; - idle_time = ioloop_time - + /* 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); + idle_time = ioloop_time - last_change; if (o_stream_get_buffer_used_size(my_client->output) > 0 && idle_time >= CLIENT_OUTPUT_TIMEOUT) {
--- a/src/imap/client.h Wed Jun 27 16:24:50 2007 +0300 +++ b/src/imap/client.h Wed Jun 27 16:38:07 2007 +0300 @@ -66,6 +66,7 @@ unsigned int disconnected:1; unsigned int destroyed:1; unsigned int handling_input:1; + unsigned int idling:1; unsigned int input_skip_line:1; /* skip all the data until we've found a new line */ };
--- a/src/imap/cmd-idle.c Wed Jun 27 16:24:50 2007 +0300 +++ b/src/imap/cmd-idle.c Wed Jun 27 16:38:07 2007 +0300 @@ -57,6 +57,7 @@ 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 @@ -259,6 +260,7 @@ 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;