Mercurial > dovecot > core-2.2
changeset 15877:69af3ef3a482
dsync: Fixed hiding the "remote command returned error" message when it was unnecessary.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Thu, 21 Feb 2013 14:15:15 +0200 |
parents | 87c206c1eaf4 |
children | fda302d15042 |
files | src/doveadm/dsync/doveadm-dsync.c |
diffstat | 1 files changed, 14 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/src/doveadm/dsync/doveadm-dsync.c Thu Feb 21 13:27:42 2013 +0200 +++ b/src/doveadm/dsync/doveadm-dsync.c Thu Feb 21 14:15:15 2013 +0200 @@ -330,14 +330,12 @@ } static void cmd_dsync_wait_remote(struct dsync_cmd_context *ctx, - bool remote_errors_logged) + int *status_r) { - int status; - /* wait for the remote command to finish to see any final errors. don't wait very long though. */ alarm(DSYNC_REMOTE_CMD_EXIT_WAIT_SECS); - if (waitpid(ctx->remote_pid, &status, 0) == -1) { + if (waitpid(ctx->remote_pid, status_r, 0) == -1) { if (errno != EINTR) { i_error("waitpid(%ld) failed: %m", (long)ctx->remote_pid); @@ -348,7 +346,15 @@ (long)ctx->remote_pid); } } - } else if (WIFSIGNALED(status)) + *status_r = -1; + } +} + +static void cmd_dsync_log_remote_status(int status, bool remote_errors_logged) +{ + if (status == -1) + ; + else if (WIFSIGNALED(status)) i_error("Remote command died with signal %d", WTERMSIG(status)); else if (!WIFEXITED(status)) i_error("Remote command failed with status %d", status); @@ -407,7 +413,7 @@ struct mail_namespace *sync_ns = NULL; enum dsync_brain_flags brain_flags; bool remote_errors_logged = FALSE; - int ret = 0; + int status, ret = 0; user->admin = TRUE; user->dsyncing = TRUE; @@ -469,7 +475,7 @@ i_close_fd(&ctx->fd_in); } if (ctx->remote) - cmd_dsync_wait_remote(ctx, remote_errors_logged); + cmd_dsync_wait_remote(ctx, &status); /* print any final errors after the process has died. not closing stdin/stdout before wait() may cause the process to hang, but stderr @@ -480,6 +486,7 @@ remote_errors_logged = ctx->err_stream->v_offset > 0; i_stream_destroy(&ctx->err_stream); } + cmd_dsync_log_remote_status(status, remote_errors_logged); if (ctx->io_err != NULL) io_remove(&ctx->io_err); if (ctx->fd_err != -1)