Mercurial > dovecot > original-hg > dovecot-1.2
changeset 8718:ea9a186d64f9 HEAD
pop3: If client idles for 10 seconds, commit transaction (allowing mbox to become unlocked).
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Wed, 04 Feb 2009 15:36:34 -0500 |
parents | 6f29380ba3a0 |
children | adc64917942c |
files | src/pop3/client.c src/pop3/client.h |
diffstat | 2 files changed, 25 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/src/pop3/client.c Wed Feb 04 15:28:31 2009 -0500 +++ b/src/pop3/client.c Wed Feb 04 15:36:34 2009 -0500 @@ -28,12 +28,26 @@ /* Disconnect client after idling this many milliseconds */ #define CLIENT_IDLE_TIMEOUT_MSECS (10*60*1000) +/* If client starts idling for this many milliseconds, commit the current + transaction. This allows the mailbox to become unlocked. */ +#define CLIENT_COMMIT_TIMEOUT_MSECS (10*1000) static struct client *my_client; /* we don't need more than one currently */ static void client_input(struct client *client); static int client_output(struct client *client); +static void client_commit_timeout(struct client *client) +{ + if (client->cmd != NULL) { + /* Can't commit while commands are running */ + return; + } + + (void)mailbox_transaction_commit(&client->trans); + client->trans = mailbox_transaction_begin(client->mailbox, 0); +} + static void client_idle_timeout(struct client *client) { if (client->cmd != NULL) { @@ -162,6 +176,10 @@ client->last_input = ioloop_time; client->to_idle = timeout_add(CLIENT_IDLE_TIMEOUT_MSECS, client_idle_timeout, client); + if (!lock_session) { + client->to_commit = timeout_add(CLIENT_COMMIT_TIMEOUT_MSECS, + client_commit_timeout, client); + } client->user = user; @@ -284,6 +302,8 @@ if (client->io != NULL) io_remove(&client->io); timeout_remove(&client->to_idle); + if (client->to_commit != NULL) + timeout_remove(&client->to_commit); i_stream_destroy(&client->input); o_stream_destroy(&client->output); @@ -429,6 +449,8 @@ client->waiting_input = FALSE; client->last_input = ioloop_time; timeout_reset(client->to_idle); + if (client->to_commit != NULL) + timeout_reset(client->to_commit); switch (i_stream_read(client->input)) { case -1: @@ -456,6 +478,8 @@ client->last_output = ioloop_time; timeout_reset(client->to_idle); + if (client->to_commit != NULL) + timeout_reset(client->to_commit); if (client->cmd != NULL) { o_stream_cork(client->output);