dovecot-2.2: dsync: If dsync was started via doveadm-server, sho...

dovecot at dovecot.org dovecot at dovecot.org
Mon Apr 28 15:24:45 UTC 2014


details:   http://hg.dovecot.org/dovecot-2.2/rev/fac4e7320676
changeset: 17279:fac4e7320676
user:      Timo Sirainen <tss at iki.fi>
date:      Mon Apr 28 18:24:04 2014 +0300
description:
dsync: If dsync was started via doveadm-server, show the remote client's IP address in ps output.

diffstat:

 src/doveadm/dsync/doveadm-dsync.c |  17 ++++++++++++++---
 src/doveadm/dsync/dsync-brain.c   |   8 +++++++-
 src/doveadm/dsync/dsync-brain.h   |   3 ++-
 3 files changed, 23 insertions(+), 5 deletions(-)

diffs (112 lines):

diff -r 00efbe39263f -r fac4e7320676 src/doveadm/dsync/doveadm-dsync.c
--- a/src/doveadm/dsync/doveadm-dsync.c	Sun Apr 27 19:05:38 2014 +0300
+++ b/src/doveadm/dsync/doveadm-dsync.c	Mon Apr 28 18:24:04 2014 +0300
@@ -369,7 +369,7 @@
 		return -1;
 	}
 
-	brain2 = dsync_brain_slave_init(user2, ibc2, TRUE);
+	brain2 = dsync_brain_slave_init(user2, ibc2, TRUE, "");
 	mail_user_unref(&user2);
 
 	brain1_running = brain2_running = TRUE;
@@ -532,6 +532,11 @@
 	int status = 0, ret = 0;
 
 	memset(&set, 0, sizeof(set));
+	if (_ctx->cur_client_ip.family != 0) {
+		/* include the doveadm client's IP address in the ps output */
+		set.process_title_prefix = t_strdup_printf(
+			"%s ", net_ip2addr(&_ctx->cur_client_ip));
+	}
 	set.sync_box = ctx->mailbox;
 	memcpy(set.sync_box_guid, ctx->mailbox_guid, sizeof(set.sync_box_guid));
 	set.lock_timeout_secs = ctx->lock_timeout;
@@ -1002,7 +1007,7 @@
 	struct dsync_brain *brain;
 	string_t *temp_prefix, *state_str = NULL;
 	enum dsync_brain_sync_type sync_type;
-	const char *name;
+	const char *name, *process_title_prefix = "";
 
 	if (_ctx->conn != NULL) {
 		/* doveadm-server connection. start with a success reply.
@@ -1013,6 +1018,12 @@
 		o_stream_nsend(ctx->output, "\n+\n", 3);
 		i_set_failure_prefix("dsync-server(%s): ", user->username);
 		name = i_stream_get_name(ctx->input);
+
+		if (_ctx->cur_client_ip.family != 0) {
+			/* include the doveadm client's IP address in the ps output */
+			process_title_prefix = t_strdup_printf(
+				"%s ", net_ip2addr(&_ctx->cur_client_ip));
+		}
 	} else {
 		/* the log messages go via stderr to the remote dsync,
 		   so the names are reversed */
@@ -1026,7 +1037,7 @@
 	mail_user_set_get_temp_prefix(temp_prefix, user->set);
 
 	ibc = cmd_dsync_icb_stream_init(ctx, name, str_c(temp_prefix));
-	brain = dsync_brain_slave_init(user, ibc, FALSE);
+	brain = dsync_brain_slave_init(user, ibc, FALSE, process_title_prefix);
 
 	io_loop_run(current_ioloop);
 
diff -r 00efbe39263f -r fac4e7320676 src/doveadm/dsync/dsync-brain.c
--- a/src/doveadm/dsync/dsync-brain.c	Sun Apr 27 19:05:38 2014 +0300
+++ b/src/doveadm/dsync/dsync-brain.c	Mon Apr 28 18:24:04 2014 +0300
@@ -41,6 +41,8 @@
 	const char *import_title, *export_title;
 
 	str_append_c(str, '[');
+	if (brain->process_title_prefix != NULL)
+		str_append(str, brain->process_title_prefix);
 	str_append(str, brain->user->username);
 	if (brain->box == NULL) {
 		str_append_c(str, ' ');
@@ -155,6 +157,8 @@
 	i_assert(N_ELEMENTS(dsync_state_names) == DSYNC_STATE_DONE+1);
 
 	brain = dsync_brain_common_init(user, ibc);
+	brain->process_title_prefix =
+		p_strdup(brain->pool, set->process_title_prefix);
 	brain->sync_type = sync_type;
 	if (array_count(&set->sync_namespaces) > 0) {
 		sync_ns_str = t_str_new(128);
@@ -219,12 +223,14 @@
 
 struct dsync_brain *
 dsync_brain_slave_init(struct mail_user *user, struct dsync_ibc *ibc,
-		       bool local)
+		       bool local, const char *process_title_prefix)
 {
 	struct dsync_ibc_settings ibc_set;
 	struct dsync_brain *brain;
 
 	brain = dsync_brain_common_init(user, ibc);
+	brain->process_title_prefix =
+		p_strdup(brain->pool, process_title_prefix);
 	brain->state = DSYNC_STATE_SLAVE_RECV_HANDSHAKE;
 
 	if (local) {
diff -r 00efbe39263f -r fac4e7320676 src/doveadm/dsync/dsync-brain.h
--- a/src/doveadm/dsync/dsync-brain.h	Sun Apr 27 19:05:38 2014 +0300
+++ b/src/doveadm/dsync/dsync-brain.h	Mon Apr 28 18:24:04 2014 +0300
@@ -38,6 +38,7 @@
 };
 
 struct dsync_brain_settings {
+	const char *process_title_prefix;
 	/* Sync only these namespaces */
 	ARRAY(struct mail_namespace *) sync_namespaces;
 	/* Sync only this mailbox name */
@@ -61,7 +62,7 @@
 			const struct dsync_brain_settings *set);
 struct dsync_brain *
 dsync_brain_slave_init(struct mail_user *user, struct dsync_ibc *ibc,
-		       bool local);
+		       bool local, const char *process_title_prefix);
 /* Returns 0 if everything was successful, -1 if syncing failed in some way */
 int dsync_brain_deinit(struct dsync_brain **brain);
 


More information about the dovecot-cvs mailing list