o_stream_unref(&output);
}
-void client_input(struct client *client)
+static void client_input(struct client *client)
{
if (client_input_read(client) < 0)
return;
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)
{
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;
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);
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);
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);
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);