changeset 16240:f55fbfc909d1

dsync: Fixed crashes with dsync-server -U parameter
author Timo Sirainen <tss@iki.fi>
date Mon, 08 Apr 2013 01:56:25 +0300
parents 57960f02d1bb
children ae4341d0e83b
files src/doveadm/dsync/doveadm-dsync.c
diffstat 1 files changed, 7 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/src/doveadm/dsync/doveadm-dsync.c	Mon Apr 08 00:18:56 2013 +0300
+++ b/src/doveadm/dsync/doveadm-dsync.c	Mon Apr 08 01:56:25 2013 +0300
@@ -909,7 +909,7 @@
 	struct dsync_cmd_context *ctx = (struct dsync_cmd_context *)_ctx;
 	struct dsync_ibc *ibc;
 	struct dsync_brain *brain;
-	string_t *temp_prefix;
+	string_t *temp_prefix, *state_str = NULL;
 
 	if (_ctx->conn != NULL) {
 		/* doveadm-server connection. start with a success reply.
@@ -933,6 +933,11 @@
 
 	io_loop_run(current_ioloop);
 
+	if (ctx->replicator_notify) {
+		state_str = t_str_new(128);
+		dsync_brain_get_state(brain, state_str);
+	}
+
 	if (dsync_brain_deinit(&brain) < 0)
 		_ctx->exit_code = EX_TEMPFAIL;
 	dsync_ibc_deinit(&ibc);
@@ -943,12 +948,8 @@
 		o_stream_close(_ctx->conn->output);
 	}
 
-	if (ctx->replicator_notify) {
-		string_t *state_str = t_str_new(128);
-		dsync_brain_get_state(brain, state_str);
+	if (ctx->replicator_notify)
 		dsync_replicator_notify(ctx, str_c(state_str));
-	}
-
 	return _ctx->exit_code == 0 ? 0 : -1;
 }