dovecot-2.2: dsync: Print remote's stderr line-buffered.
dovecot at dovecot.org
dovecot at dovecot.org
Tue Jan 8 10:25:31 EET 2013
details: http://hg.dovecot.org/dovecot-2.2/rev/6ff774dc0b6e
changeset: 15595:6ff774dc0b6e
user: Timo Sirainen <tss at iki.fi>
date: Tue Jan 08 10:25:21 2013 +0200
description:
dsync: Print remote's stderr line-buffered.
Especially when debugging is enabled there can be a lot of output, which
makes this useful.
diffstat:
src/doveadm/dsync/doveadm-dsync.c | 25 ++++++++++++++-----------
1 files changed, 14 insertions(+), 11 deletions(-)
diffs (65 lines):
diff -r 5bb80a6491eb -r 6ff774dc0b6e src/doveadm/dsync/doveadm-dsync.c
--- a/src/doveadm/dsync/doveadm-dsync.c Tue Jan 08 07:43:29 2013 +0200
+++ b/src/doveadm/dsync/doveadm-dsync.c Tue Jan 08 10:25:21 2013 +0200
@@ -40,6 +40,7 @@
int fd_in, fd_out, fd_err;
struct io *io_err;
+ struct istream *err_stream;
unsigned int lock_timeout;
@@ -55,18 +56,13 @@
static void remote_error_input(struct dsync_cmd_context *ctx)
{
- char buf[1024];
- ssize_t ret;
+ const char *line;
- ret = read(ctx->fd_err, buf, sizeof(buf)-1);
- if (ret == -1) {
+ while ((line = i_stream_read_next_line(ctx->err_stream)) != NULL)
+ i_error("remote: %s", line);
+
+ if (ctx->err_stream->eof)
io_remove(&ctx->io_err);
- return;
- }
- if (ret > 0) {
- buf[ret-1] = '\0';
- i_error("remote: %s", buf);
- }
}
static void
@@ -107,7 +103,8 @@
ctx->fd_in = fd_out[0];
ctx->fd_out = fd_in[1];
ctx->fd_err = fd_err[0];
- ctx->io_err = io_add(ctx->fd_err, IO_READ, remote_error_input, ctx);
+ ctx->err_stream = i_stream_create_fd(ctx->fd_err, IO_BLOCK_SIZE, FALSE);
+ i_stream_set_return_partial_line(ctx->err_stream, TRUE);
}
static void
@@ -374,6 +371,8 @@
mail_user_set_get_temp_prefix(temp_prefix, user->set);
ibc = cmd_dsync_icb_stream_init(ctx, ctx->remote_name,
str_c(temp_prefix));
+ ctx->io_err = io_add(ctx->fd_err, IO_READ,
+ remote_error_input, ctx);
}
brain_flags = DSYNC_BRAIN_FLAG_MAILS_HAVE_GUIDS |
@@ -411,6 +410,10 @@
dsync_ibc_deinit(&ibc);
if (ibc2 != NULL)
dsync_ibc_deinit(&ibc2);
+ if (ctx->err_stream != NULL) {
+ remote_error_input(ctx); /* print any pending errors */
+ i_stream_destroy(&ctx->err_stream);
+ }
if (ctx->io_err != NULL)
io_remove(&ctx->io_err);
if (ctx->fd_in != -1) {
More information about the dovecot-cvs
mailing list