dovecot-2.2-pigeonhole: managesieve: Compared to imap and incorp...
pigeonhole at rename-it.nl
pigeonhole at rename-it.nl
Wed Jun 18 22:11:12 UTC 2014
details: http://hg.rename-it.nl/dovecot-2.2-pigeonhole/rev/d5620195d79c
changeset: 1881:d5620195d79c
user: Stephan Bosch <stephan at rename-it.nl>
date: Thu Jun 19 00:10:53 2014 +0200
description:
managesieve: Compared to imap and incorporated a few differences from there.
Most important change is that mail service_user was not freed.
diffstat:
src/managesieve/main.c | 26 ++++++++++++++++----------
src/managesieve/managesieve-client.c | 35 +++++++++++++++++++++--------------
2 files changed, 37 insertions(+), 24 deletions(-)
diffs (173 lines):
diff -r b56520e04882 -r d5620195d79c src/managesieve/main.c
--- a/src/managesieve/main.c Wed Jun 18 00:08:03 2014 +0200
+++ b/src/managesieve/main.c Thu Jun 19 00:10:53 2014 +0200
@@ -12,6 +12,7 @@
#include "process-title.h"
#include "restrict-access.h"
#include "fd-close-on-exec.h"
+#include "settings-parser.h"
#include "master-interface.h"
#include "master-service.h"
#include "master-login.h"
@@ -128,7 +129,7 @@
struct mail_storage_service_user *user;
struct mail_user *mail_user;
struct client *client;
- const struct managesieve_settings *set;
+ struct managesieve_settings *set;
if (mail_storage_service_lookup_next(storage_service, input,
&user, &mail_user, error_r) <= 0)
@@ -139,6 +140,9 @@
if (set->verbose_proctitle)
verbose_proctitle = TRUE;
+ settings_var_expand(&managesieve_setting_parser_info, set, mail_user->pool,
+ mail_user_var_expand_table(mail_user));
+
client = client_create
(fd_in, fd_out, input->session_id, mail_user, user, set);
T_BEGIN {
@@ -195,13 +199,15 @@
client->auth_req.data_size);
if (client_create_from_input(&input, client->fd, client->fd,
&input_buf, &error) < 0) {
- if (write(client->fd, MSG_BYE_INTERNAL_ERROR,
+ int fd = client->fd;
+
+ if (write(fd, MSG_BYE_INTERNAL_ERROR,
strlen(MSG_BYE_INTERNAL_ERROR)) < 0) {
if (errno != EAGAIN && errno != EPIPE)
i_error("write(client) failed: %m");
}
i_error("%s", error);
- (void)close(client->fd);
+ i_close_fd(&fd);
master_service_client_connection_destroyed(master_service);
}
}
@@ -276,13 +282,6 @@
}
}
- login_set.auth_socket_path = t_abspath("auth-master");
- if (argv[optind] != NULL)
- login_set.postlogin_socket_path = t_abspath(argv[optind]);
- login_set.callback = login_client_connected;
- login_set.failure_callback = login_client_failed;
-
- master_service_init_finish(master_service);
master_service_set_die_callback(master_service, managesieve_die);
/* plugins may want to add commands, so this needs to be called early */
@@ -297,6 +296,7 @@
storage_service =
mail_storage_service_init(master_service,
set_roots, storage_service_flags);
+ master_service_init_finish(master_service);
/* fake that we're running, so we know if client was destroyed
while handling its initial input */
@@ -307,6 +307,12 @@
main_stdio_run(username);
} T_END;
} else {
+ login_set.auth_socket_path = t_abspath("auth-master");
+ if (argv[optind] != NULL)
+ login_set.postlogin_socket_path = t_abspath(argv[optind]);
+ login_set.callback = login_client_connected;
+ login_set.failure_callback = login_client_failed;
+
master_login = master_login_init(master_service, &login_set);
io_loop_set_running(current_ioloop);
}
diff -r b56520e04882 -r d5620195d79c src/managesieve/managesieve-client.c
--- a/src/managesieve/managesieve-client.c Wed Jun 18 00:08:03 2014 +0200
+++ b/src/managesieve/managesieve-client.c Thu Jun 19 00:10:53 2014 +0200
@@ -102,11 +102,6 @@
struct sieve_storage *storage;
pool_t pool;
- /* Always use nonblocking I/O */
-
- net_set_nonblock(fd_in, TRUE);
- net_set_nonblock(fd_out, TRUE);
-
/* Initialize Sieve instance */
memset((void*)&svenv, 0, sizeof(svenv));
@@ -138,9 +133,13 @@
(fd_in, set->managesieve_max_line_length, FALSE);
client->output = o_stream_create_fd(fd_out, (size_t)-1, FALSE);
+ o_stream_set_no_error_handling(client->output, TRUE);
+ i_stream_set_name(client->input, "<managesieve client>");
+ o_stream_set_name(client->output, "<managesieve client>");
+
o_stream_set_flush_callback(client->output, client_output, client);
- client->io = io_add(fd_in, IO_READ, client_input, client);
+ client->io = io_add_istream(client->input, client_input, client);
client->last_input = ioloop_time;
client->parser = managesieve_parser_create
(client->input, set->managesieve_max_line_length);
@@ -185,7 +184,7 @@
tab = t_malloc(sizeof(static_tab));
memcpy(tab, static_tab, sizeof(static_tab));
- tab[0].value = dec2str(client->input->v_offset);
+ tab[0].value = dec2str(i_stream_get_absolute_offset(client->input));
tab[1].value = dec2str(client->output->offset);
tab[2].value = client->session_id;
@@ -249,17 +248,15 @@
i_stream_destroy(&client->input);
o_stream_destroy(&client->output);
- if (close(client->fd_in) < 0)
- i_error("close(client in) failed: %m");
- if (client->fd_in != client->fd_out) {
- if (close(client->fd_out) < 0)
- i_error("close(client out) failed: %m");
- }
+ net_disconnect(client->fd_in);
+ if (client->fd_in != client->fd_out)
+ net_disconnect(client->fd_out);
sieve_storage_free(client->storage);
sieve_deinit(&client->svinst);
pool_unref(&client->cmd.pool);
+ mail_storage_service_user_free(&client->service_user);
managesieve_client_count--;
DLLIST_REMOVE(&managesieve_clients, client);
@@ -269,6 +266,11 @@
managesieve_refresh_proctitle();
}
+static void client_destroy_timeout(struct client *client)
+{
+ client_destroy(client, NULL);
+}
+
void client_disconnect(struct client *client, const char *reason)
{
i_assert(reason != NULL);
@@ -278,10 +280,15 @@
i_info("Disconnected: %s %s", reason, client_stats(client));
client->disconnected = TRUE;
- (void)o_stream_flush(client->output);
+ o_stream_flush(client->output);
+ o_stream_uncork(client->output);
i_stream_close(client->input);
o_stream_close(client->output);
+
+ if (client->to_idle != NULL)
+ timeout_remove(&client->to_idle);
+ client->to_idle = timeout_add(0, client_destroy_timeout, client);
}
void client_disconnect_with_error(struct client *client, const char *msg)
More information about the dovecot-cvs
mailing list