Mercurial > dovecot > core-2.2
changeset 10283:cb7b2901f1f8 HEAD
lmtp: Disable idle timeout while proxying.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Mon, 09 Nov 2009 18:54:40 -0500 |
parents | 7215f4142901 |
children | 2ad1ad1e1083 |
files | src/lmtp/client.c src/lmtp/client.h src/lmtp/commands.c |
diffstat | 3 files changed, 17 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lmtp/client.c Mon Nov 09 18:41:59 2009 -0500 +++ b/src/lmtp/client.c Mon Nov 09 18:54:40 2009 -0500 @@ -112,7 +112,7 @@ o_stream_unref(&output); } -void client_input(struct client *client) +static void client_input(struct client *client) { if (client_input_read(client) < 0) return; @@ -188,6 +188,16 @@ return addr; } +void client_io_reset(struct client *client) +{ + if (client->io != NULL) + io_remove(&client->io); + client->io = io_add(client->fd_in, IO_READ, client_input, client); + client->last_input = ioloop_time; + client->to_idle = timeout_add(CLIENT_IDLE_TIMEOUT_MSECS, + client_idle_timeout, client); +} + struct client *client_create(int fd_in, int fd_out, const struct master_service_connection *conn) { @@ -210,10 +220,7 @@ client->input = i_stream_create_fd(fd_in, CLIENT_MAX_INPUT_SIZE, FALSE); client->output = o_stream_create_fd(fd_out, (size_t)-1, FALSE); - client->io = io_add(fd_in, IO_READ, client_input, client); - client->last_input = ioloop_time; - client->to_idle = timeout_add(CLIENT_IDLE_TIMEOUT_MSECS, - client_idle_timeout, client); + client_io_reset(client); client->my_domain = my_hostname; client->state_pool = pool_alloconly_create("client state", 4096); client->state.mail_data_fd = -1; @@ -245,7 +252,8 @@ lmtp_proxy_deinit(&client->proxy); if (client->io != NULL) io_remove(&client->io); - timeout_remove(&client->to_idle); + if (client->to_idle != NULL) + timeout_remove(&client->to_idle); i_stream_destroy(&client->input); o_stream_destroy(&client->output);
--- a/src/lmtp/client.h Mon Nov 09 18:41:59 2009 -0500 +++ b/src/lmtp/client.h Mon Nov 09 18:54:40 2009 -0500 @@ -73,9 +73,9 @@ const char *reason); void client_disconnect(struct client *client, const char *prefix, const char *reason); +void client_io_reset(struct client *client); void client_state_reset(struct client *client); -void client_input(struct client *client); void client_input_handle(struct client *client); int client_input_read(struct client *client);
--- a/src/lmtp/commands.c Mon Nov 09 18:41:59 2009 -0500 +++ b/src/lmtp/commands.c Mon Nov 09 18:54:40 2009 -0500 @@ -593,10 +593,7 @@ static void client_input_data_finish(struct client *client) { - if (client->io != NULL) - io_remove(&client->io); - client->io = io_add(client->fd_in, IO_READ, client_input, client); - + client_io_reset(client); client_state_reset(client); if (i_stream_have_bytes_left(client->input)) client_input_handle(client); @@ -754,6 +751,7 @@ io_remove(&client->io); if (array_count(&client->state.rcpt_to) == 0) { + timeout_remove(&client->to_idle); lmtp_proxy_start(client->proxy, client->dot_input, client_proxy_finish, client); i_stream_unref(&client->dot_input);