]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lmtp: Disable idle timeout while proxying.
authorTimo Sirainen <tss@iki.fi>
Mon, 9 Nov 2009 23:54:40 +0000 (18:54 -0500)
committerTimo Sirainen <tss@iki.fi>
Mon, 9 Nov 2009 23:54:40 +0000 (18:54 -0500)
--HG--
branch : HEAD

src/lmtp/client.c
src/lmtp/client.h
src/lmtp/commands.c

index 5a0bce0462eba0ce9350b6281b7764c73837cd43..943d9d33560be870766f32e92506c4afcde1d8d8 100644 (file)
@@ -112,7 +112,7 @@ void client_input_handle(struct client *client)
        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 @@ static const char *client_remote_id(struct client *client)
        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 @@ struct client *client_create(int fd_in, int fd_out,
        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 @@ void client_destroy(struct client *client, const char *prefix,
                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);
 
index 6d24d5a90dc2b31a0b46902fde0c2aef5bbf458a..e2feac964671e04130df34c7bf72754066764288 100644 (file)
@@ -73,9 +73,9 @@ void client_destroy(struct client *client, const char *prefix,
                    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);
 
index 8cfc9aba168e02d1e06889b954d4ee3346399dab..565bc278a7540aadefbada9f123c70ca340a1020 100644 (file)
@@ -593,10 +593,7 @@ client_input_data_write_local(struct client *client, struct istream *input)
 
 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 @@ int cmd_data(struct client *client, const char *args ATTR_UNUSED)
 
        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);