From: Timo Sirainen Date: Thu, 1 Sep 2011 02:57:42 +0000 (+0300) Subject: doveadm stats top: Don't hang if stats server doesn't send any statistics. X-Git-Tag: 2.1.alpha1~20 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=650cd8feabfc3f7ed9847cfe429e4ad4f9e32bd9;p=thirdparty%2Fdovecot%2Fcore.git doveadm stats top: Don't hang if stats server doesn't send any statistics. --- diff --git a/src/doveadm/doveadm-stats.c b/src/doveadm/doveadm-stats.c index e5017ae048..24aa95ab77 100644 --- a/src/doveadm/doveadm-stats.c +++ b/src/doveadm/doveadm-stats.c @@ -46,21 +46,25 @@ static void stats_lookup(const char *path) args = read_next_line(input); if (args == NULL) i_fatal("read(%s) unexpectedly disconnected", path); - for (; *args != NULL; args++) - doveadm_print_header_simple(*args); + if (*args == NULL) + i_info("no statistics available"); + else { + for (; *args != NULL; args++) + doveadm_print_header_simple(*args); - /* read lines */ - do { - T_BEGIN { - args = read_next_line(input); - if (args[0] == NULL) - args = NULL; - if (args != NULL) { - for (i = 0; args[i] != NULL; i++) - doveadm_print(args[i]); - } - } T_END; - } while (args != NULL); + /* read lines */ + do { + T_BEGIN { + args = read_next_line(input); + if (args[0] == NULL) + args = NULL; + if (args != NULL) { + for (i = 0; args[i] != NULL; i++) + doveadm_print(args[i]); + } + } T_END; + } while (args != NULL); + } if (input->stream_errno != 0) i_fatal("read(%s) failed: %m", path); i_stream_destroy(&input);