Mercurial > dovecot > core-2.2
changeset 13368:1c2d8da38a06
stats: Log more verbosely what happened if stats shrink.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Thu, 01 Sep 2011 17:52:51 +0300 |
parents | ea0b4da3ceef |
children | 338ba56340c0 |
files | src/stats/mail-command.c src/stats/mail-session.c src/stats/mail-stats.c src/stats/mail-stats.h |
diffstat | 4 files changed, 33 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/src/stats/mail-command.c Thu Sep 01 12:34:11 2011 +0300 +++ b/src/stats/mail-command.c Thu Sep 01 17:52:51 2011 +0300 @@ -94,6 +94,7 @@ struct mail_session *session; struct mail_command *cmd; struct mail_stats stats, diff_stats; + const char *error; unsigned int cmd_id; bool done; int ret; @@ -134,8 +135,10 @@ if (session->ip != NULL) session->ip->num_cmds++; } else { - if (!mail_stats_diff(&cmd->stats, &stats, &diff_stats)) { - *error_r = "UPDATE-SESSION: stats shrank"; + if (!mail_stats_diff(&cmd->stats, &stats, &diff_stats, + &error)) { + *error_r = t_strconcat("UPDATE-SESSION: stats shrank: ", + error, NULL); return -1; } cmd->last_update = ioloop_timeval;
--- a/src/stats/mail-session.c Thu Sep 01 12:34:11 2011 +0300 +++ b/src/stats/mail-session.c Thu Sep 01 17:52:51 2011 +0300 @@ -201,6 +201,7 @@ { struct mail_session *session; struct mail_stats stats, diff_stats; + const char *error; int ret; /* <session guid> [key=value ..] */ @@ -212,8 +213,9 @@ return -1; } - if (!mail_stats_diff(&session->stats, &stats, &diff_stats)) { - *error_r = "UPDATE-SESSION: stats shrank"; + if (!mail_stats_diff(&session->stats, &stats, &diff_stats, &error)) { + *error_r = t_strconcat("UPDATE-SESSION: stats shrank: ", + error, NULL); return -1; } mail_session_refresh(session, &diff_stats);
--- a/src/stats/mail-stats.c Thu Sep 01 12:34:11 2011 +0300 +++ b/src/stats/mail-stats.c Thu Sep 01 17:52:51 2011 +0300 @@ -162,7 +162,7 @@ bool mail_stats_diff(const struct mail_stats *stats1, const struct mail_stats *stats2, - struct mail_stats *diff_stats_r) + struct mail_stats *diff_stats_r, const char **error_r) { unsigned int i; @@ -178,20 +178,39 @@ case TYPE_NUM: switch (parse_map[i].size) { case sizeof(uint32_t): - if (!mail_stats_diff_uint32(dest, src1, src2)) + if (!mail_stats_diff_uint32(dest, src1, src2)) { + *error_r = t_strdup_printf("%s %u < %u", + parse_map[i].name, + *(const uint32_t *)src2, + *(const uint32_t *)src1); return FALSE; + } break; case sizeof(uint64_t): - if (!mail_stats_diff_uint64(dest, src1, src2)) + if (!mail_stats_diff_uint64(dest, src1, src2)) { + const uint64_t *n1 = src1, *n2 = src2; + + *error_r = t_strdup_printf("%s %llu < %llu", + parse_map[i].name, + (unsigned long long)n2, + (unsigned long long)n1); return FALSE; + } break; default: i_unreached(); } break; case TYPE_TIMEVAL: - if (!mail_stats_diff_timeval(dest, src1, src2)) + if (!mail_stats_diff_timeval(dest, src1, src2)) { + const struct timeval *tv1 = src1, *tv2 = src2; + + *error_r = t_strdup_printf("%s %ld.%d < %ld.%d", + parse_map[i].name, + (long)tv2->tv_sec, (int)tv2->tv_usec, + (long)tv1->tv_sec, (int)tv1->tv_usec); return FALSE; + } break; } }
--- a/src/stats/mail-stats.h Thu Sep 01 12:34:11 2011 +0300 +++ b/src/stats/mail-stats.h Thu Sep 01 17:52:51 2011 +0300 @@ -107,7 +107,7 @@ is so, FALSE if not */ bool mail_stats_diff(const struct mail_stats *stats1, const struct mail_stats *stats2, - struct mail_stats *diff_stats_r); + struct mail_stats *diff_stats_r, const char **error_r); void mail_stats_add(struct mail_stats *dest, const struct mail_stats *src); #endif