Mercurial > dovecot > core-2.2
changeset 11591:4e54843f11d0 HEAD
doveadm: Output flushing fixes.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Mon, 21 Jun 2010 15:34:48 +0100 |
parents | 542d859f0223 |
children | 08b879b79236 |
files | src/doveadm/doveadm-mail.c src/doveadm/doveadm-print-flow.c src/doveadm/doveadm-print-private.h src/doveadm/doveadm-print-tab.c src/doveadm/doveadm-print-table.c src/doveadm/doveadm-print.c src/doveadm/doveadm-print.h |
diffstat | 7 files changed, 41 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/src/doveadm/doveadm-mail.c Mon Jun 21 15:26:00 2010 +0100 +++ b/src/doveadm/doveadm-mail.c Mon Jun 21 15:34:48 2010 +0100 @@ -397,6 +397,7 @@ doveadm_mail_all_users(ctx, wildcard_user, service_flags); } ctx->v.deinit(ctx); + doveadm_print_flush(); if (ctx->failed) exit(FATAL_DEFAULT);
--- a/src/doveadm/doveadm-print-flow.c Mon Jun 21 15:26:00 2010 +0100 +++ b/src/doveadm/doveadm-print-flow.c Mon Jun 21 15:34:48 2010 +0100 @@ -56,11 +56,16 @@ p_array_init(&ctx->headers, pool, 16); } +static void doveadm_print_flow_flush(void) +{ + if (ctx->header_idx != 0) { + printf("\n"); + ctx->header_idx = 0; + } +} + static void doveadm_print_flow_deinit(void) { - if (ctx->header_idx != 0) - printf("\n"); - pool_unref(&ctx->pool); ctx = NULL; } @@ -71,5 +76,6 @@ doveadm_print_flow_init, doveadm_print_flow_deinit, doveadm_print_flow_header, - doveadm_print_flow_print + doveadm_print_flow_print, + doveadm_print_flow_flush };
--- a/src/doveadm/doveadm-print-private.h Mon Jun 21 15:26:00 2010 +0100 +++ b/src/doveadm/doveadm-print-private.h Mon Jun 21 15:34:48 2010 +0100 @@ -17,6 +17,7 @@ void (*header)(const struct doveadm_print_header *hdr); void (*print)(const char *value); + void (*flush)(void); }; extern struct doveadm_print_vfuncs doveadm_print_flow_vfuncs;
--- a/src/doveadm/doveadm-print-tab.c Mon Jun 21 15:26:00 2010 +0100 +++ b/src/doveadm/doveadm-print-tab.c Mon Jun 21 15:34:48 2010 +0100 @@ -40,17 +40,20 @@ } } -static void doveadm_print_tab_deinit(void) +static void doveadm_print_tab_flush(void) { - if (!ctx.header_written) + if (!ctx.header_written) { printf("\n"); + ctx.header_written = TRUE; + } } struct doveadm_print_vfuncs doveadm_print_tab_vfuncs = { "tab", NULL, - doveadm_print_tab_deinit, + NULL, doveadm_print_tab_header, - doveadm_print_tab_print + doveadm_print_tab_print, + doveadm_print_tab_flush };
--- a/src/doveadm/doveadm-print-table.c Mon Jun 21 15:26:00 2010 +0100 +++ b/src/doveadm/doveadm-print-table.c Mon Jun 21 15:34:48 2010 +0100 @@ -51,6 +51,8 @@ unsigned int i, line, len, hdr_count, value_count, line_count; unsigned int max_length, orig_length, diff; + ctx->lengths_set = TRUE; + headers = array_get_modifiable(&ctx->headers, &hdr_count); values = array_get(&ctx->buffered_values, &value_count); i_assert((value_count % hdr_count) == 0); @@ -169,6 +171,12 @@ doveadm_print_next(value); } +static void doveadm_print_table_flush(void) +{ + if (!ctx->lengths_set && array_count(&ctx->headers) > 0) + doveadm_buffer_flush(); +} + static void doveadm_print_table_init(void) { pool_t pool; @@ -189,9 +197,6 @@ static void doveadm_print_table_deinit(void) { - if (!ctx->lengths_set && array_count(&ctx->headers) > 0) - doveadm_buffer_flush(); - array_free(&ctx->buffered_values); pool_unref(&ctx->pool); ctx = NULL; @@ -203,5 +208,6 @@ doveadm_print_table_init, doveadm_print_table_deinit, doveadm_print_table_header, - doveadm_print_table_print + doveadm_print_table_print, + doveadm_print_table_flush };
--- a/src/doveadm/doveadm-print.c Mon Jun 21 15:26:00 2010 +0100 +++ b/src/doveadm/doveadm-print.c Mon Jun 21 15:34:48 2010 +0100 @@ -4,6 +4,8 @@ #include "array.h" #include "doveadm-print-private.h" +#include <stdio.h> + struct doveadm_print_header_context { const char *key; char *sticky_value; @@ -102,6 +104,13 @@ i_unreached(); } +void doveadm_print_flush(void) +{ + if (ctx != NULL && ctx->v->flush != NULL) + ctx->v->flush(); + fflush(stdout); +} + void doveadm_print_init(const char *name) { pool_t pool; @@ -136,6 +145,8 @@ if (ctx == NULL) return; + if (ctx->v->flush != NULL) + ctx->v->flush(); ctx->v->deinit(); array_foreach_modifiable(&ctx->headers, hdr) i_free(hdr->sticky_value);
--- a/src/doveadm/doveadm-print.h Mon Jun 21 15:26:00 2010 +0100 +++ b/src/doveadm/doveadm-print.h Mon Jun 21 15:34:48 2010 +0100 @@ -18,6 +18,7 @@ void doveadm_print(const char *value); void doveadm_print_num(uintmax_t value); void doveadm_print_sticky(const char *key, const char *value); +void doveadm_print_flush(void); void doveadm_print_init(const char *name); void doveadm_print_deinit(void);