dovecot-2.2: dsync: Name remote connections better.

dovecot at dovecot.org dovecot at dovecot.org
Tue Aug 6 14:26:11 EEST 2013


details:   http://hg.dovecot.org/dovecot-2.2/rev/ef5518ee5ab2
changeset: 16663:ef5518ee5ab2
user:      Timo Sirainen <tss at iki.fi>
date:      Tue Aug 06 14:25:49 2013 +0300
description:
dsync: Name remote connections better.

diffstat:

 src/doveadm/client-connection.c   |   3 +++
 src/doveadm/dsync/doveadm-dsync.c |  13 ++++++++++---
 2 files changed, 13 insertions(+), 3 deletions(-)

diffs (49 lines):

diff -r 820f4dbaebdd -r ef5518ee5ab2 src/doveadm/client-connection.c
--- a/src/doveadm/client-connection.c	Tue Aug 06 12:48:15 2013 +0300
+++ b/src/doveadm/client-connection.c	Tue Aug 06 14:25:49 2013 +0300
@@ -411,6 +411,9 @@
 	(void)net_getsockname(fd, &conn->local_ip, &conn->local_port);
 	(void)net_getpeername(fd, &conn->remote_ip, &conn->remote_port);
 
+	i_stream_set_name(conn->input, net_ip2addr(&conn->remote_ip));
+	o_stream_set_name(conn->output, net_ip2addr(&conn->remote_ip));
+
 	if (client_connection_read_settings(conn) < 0) {
 		client_connection_destroy(&conn);
 		return NULL;
diff -r 820f4dbaebdd -r ef5518ee5ab2 src/doveadm/dsync/doveadm-dsync.c
--- a/src/doveadm/dsync/doveadm-dsync.c	Tue Aug 06 12:48:15 2013 +0300
+++ b/src/doveadm/dsync/doveadm-dsync.c	Tue Aug 06 14:25:49 2013 +0300
@@ -958,6 +958,7 @@
 	struct dsync_brain *brain;
 	string_t *temp_prefix, *state_str = NULL;
 	enum dsync_brain_sync_type sync_type;
+	const char *name;
 
 	if (_ctx->conn != NULL) {
 		/* doveadm-server connection. start with a success reply.
@@ -966,15 +967,21 @@
 		ctx->input = _ctx->conn->input;
 		ctx->output = _ctx->conn->output;
 		o_stream_nsend(ctx->output, "\n+\n", 3);
+		i_set_failure_prefix("dsync-server(%s): ", user->username);
+		name = i_stream_get_name(ctx->input);
+	} else {
+		/* the log messages go via stderr to the remote dsync,
+		   so the names are reversed */
+		i_set_failure_prefix("dsync-remote(%s): ", user->username);
+		name = "local";
 	}
+
 	doveadm_user_init_dsync(user);
 
-	i_set_failure_prefix("dsync-remote(%s): ", user->username);
-
 	temp_prefix = t_str_new(64);
 	mail_user_set_get_temp_prefix(temp_prefix, user->set);
 
-	ibc = cmd_dsync_icb_stream_init(ctx, "local", str_c(temp_prefix));
+	ibc = cmd_dsync_icb_stream_init(ctx, name, str_c(temp_prefix));
 	brain = dsync_brain_slave_init(user, ibc, FALSE);
 
 	io_loop_run(current_ioloop);


More information about the dovecot-cvs mailing list