From 64c3c5394121ab9f5a93a8c6d2c48511ff720536 Mon Sep 17 00:00:00 2001 From: Matthias Andree Date: Mon, 4 May 2009 21:52:32 +0000 Subject: Major progress ticker bugfix/overhaul. Progress tickers had been used inconsistently for a long time, and documentation was outdated, too. Factor out common code to ease maintenance, use the report_flush() function, and add and use a macro (want_progress()) to determine if progress ticker output is desired. This makes for a much more consistent look on screen and in logfiles and should be much easier to fix later on. TODO: test syslog output. svn path=/branches/BRANCH_6-3/; revision=5290 --- driver.c | 53 +++++++++++++++++++++++++++++------------------------ 1 file changed, 29 insertions(+), 24 deletions(-) (limited to 'driver.c') diff --git a/driver.c b/driver.c index 335da6ac..bf4c7b5c 100644 --- a/driver.c +++ b/driver.c @@ -418,6 +418,14 @@ static void mark_oversized(struct query *ctl, int size) } } +static int eat_trailer(int sock, struct query *ctl) +{ + /* we only need this LF if we're printing ticker dots + * AND we are dumping protocol traces. */ + if (outlevel >= O_VERBOSE && want_progress()) fputc('\n', stdout); + return (ctl->server.base_protocol->trail)(sock, ctl, tag); +} + static int fetch_messages(int mailserver_socket, struct query *ctl, int count, int **msgsizes, int maxfetch, int *fetches, int *dispatches, int *deletions) @@ -615,8 +623,11 @@ static int fetch_messages(int mailserver_socket, struct query *ctl, if (len > 0) report_build(stdout, wholesize ? GT_(" (%d octets)") : GT_(" (%d header octets)"), len); - if (outlevel >= O_VERBOSE) - report_complete(stdout, "\n"); + if (want_progress()) { + /* flush and add a blank to append ticker dots */ + report_flush(stdout); + putchar(' '); + } } /* @@ -628,6 +639,7 @@ static int fetch_messages(int mailserver_socket, struct query *ctl, /* pass the suppress_readbody flag only if the underlying * protocol does not fetch the body separately */ separatefetchbody ? 0 : &suppress_readbody); + if (err == PS_RETAINED) suppress_forward = suppress_delete = retained = TRUE; else if (err == PS_TRANSIENT) @@ -640,14 +652,8 @@ static int fetch_messages(int mailserver_socket, struct query *ctl, /* tell server we got it OK and resynchronize */ if (separatefetchbody && ctl->server.base_protocol->trail) { - if (outlevel >= O_VERBOSE && !is_a_file(1) && !run.use_syslog) - { - fputc('\n', stdout); - fflush(stdout); - } - - if ((err = (ctl->server.base_protocol->trail)(mailserver_socket, ctl, tag))) - return(err); + err = eat_trailer(mailserver_socket, ctl); + if (err) return(err); } /* do not read the body which is not being forwarded only if @@ -680,9 +686,15 @@ static int fetch_messages(int mailserver_socket, struct query *ctl, */ if (len == -1) len = msgsize - msgblk.msglen; - if (outlevel > O_SILENT && !wholesize) - report_build(stdout, - GT_(" (%d body octets)"), len); + if (!wholesize) { + if (outlevel > O_SILENT) + report_build(stdout, + GT_(" (%d body octets)"), len); + if (want_progress()) { + report_flush(stdout); + putchar(' '); + } + } } /* process the body now */ @@ -690,23 +702,16 @@ static int fetch_messages(int mailserver_socket, struct query *ctl, ctl, !suppress_forward, len); + if (err == PS_TRANSIENT) suppress_delete = suppress_forward = TRUE; else if (err) return(err); /* tell server we got it OK and resynchronize */ - if (ctl->server.base_protocol->trail) - { - if (outlevel >= O_VERBOSE && !is_a_file(1) && !run.use_syslog) - { - fputc('\n', stdout); - fflush(stdout); - } - - err = (ctl->server.base_protocol->trail)(mailserver_socket, ctl, tag); - if (err != 0) - return(err); + if (ctl->server.base_protocol->trail) { + err = eat_trailer(mailserver_socket, ctl); + if (err) return(err); } } -- cgit v1.2.3