dovecot-2.1: stats: Avoid duplicate "Couldn't find session GUID"...
dovecot at dovecot.org
dovecot at dovecot.org
Mon Sep 12 14:44:10 EEST 2011
details: http://hg.dovecot.org/dovecot-2.1/rev/2492161a87f5
changeset: 13451:2492161a87f5
user: Timo Sirainen <tss at iki.fi>
date: Mon Sep 12 14:43:31 2011 +0300
description:
stats: Avoid duplicate "Couldn't find session GUID" warnings.
When it happens, just create a dummy session for it and log a warning once.
diffstat:
src/stats/mail-command.c | 5 ++---
src/stats/mail-session.c | 29 +++++++++++++++++++++++++----
src/stats/mail-session.h | 2 ++
3 files changed, 29 insertions(+), 7 deletions(-)
diffs (87 lines):
diff -r a2c62701a1c4 -r 2492161a87f5 src/stats/mail-command.c
--- a/src/stats/mail-command.c Mon Sep 12 14:40:49 2011 +0300
+++ b/src/stats/mail-command.c Mon Sep 12 14:43:31 2011 +0300
@@ -97,15 +97,14 @@
const char *error;
unsigned int cmd_id;
bool done;
- int ret;
/* <session guid> <cmd id> <done> <name> <args> [key=value ..] */
if (str_array_length(args) < 4) {
*error_r = "UPDATE-CMD: Too few parameters";
return -1;
}
- if ((ret = mail_session_lookup(args[0], &session, error_r)) <= 0)
- return ret;
+ if (mail_session_get(args[0], &session, error_r) < 0)
+ return -1;
if (str_to_uint(args[1], &cmd_id) < 0 || cmd_id == 0) {
*error_r = "UPDATE-CMD: Invalid command id";
diff -r a2c62701a1c4 -r 2492161a87f5 src/stats/mail-session.c
--- a/src/stats/mail-session.c Mon Sep 12 14:40:49 2011 +0300
+++ b/src/stats/mail-session.c Mon Sep 12 14:43:31 2011 +0300
@@ -160,13 +160,35 @@
}
*session_r = hash_table_lookup(mail_sessions_hash, session_guid);
if (*session_r == NULL) {
- i_warning("mail disconnect couldn't find session GUID: %s",
+ i_warning("Couldn't find session GUID: %s",
guid_128_to_string(session_guid));
return 0;
}
return 1;
}
+int mail_session_get(const char *guid, struct mail_session **session_r,
+ const char **error_r)
+{
+ const char *new_args[5];
+ int ret;
+
+ if ((ret = mail_session_lookup(guid, session_r, error_r)) != 0)
+ return ret;
+
+ /* Create a new dummy session to avoid repeated warnings */
+ new_args[0] = guid;
+ new_args[1] = ""; /* username */
+ new_args[2] = ""; /* service */
+ new_args[3] = "0"; /* pid */
+ new_args[4] = NULL;
+ if (mail_session_connect_parse(new_args, error_r) < 0)
+ i_unreached();
+ if (mail_session_lookup(guid, session_r, error_r) != 1)
+ i_unreached();
+ return 0;
+}
+
int mail_session_disconnect_parse(const char *const *args, const char **error_r)
{
struct mail_session *session;
@@ -203,11 +225,10 @@
struct mail_session *session;
struct mail_stats stats, diff_stats;
const char *error;
- int ret;
/* <session guid> [key=value ..] */
- if ((ret = mail_session_lookup(args[0], &session, error_r)) <= 0)
- return ret;
+ if (mail_session_get(args[0], &session, error_r) < 0)
+ return -1;
if (mail_stats_parse(args+1, &stats, error_r) < 0) {
*error_r = t_strconcat("UPDATE-SESSION: ", *error_r, NULL);
diff -r a2c62701a1c4 -r 2492161a87f5 src/stats/mail-session.h
--- a/src/stats/mail-session.h Mon Sep 12 14:40:49 2011 +0300
+++ b/src/stats/mail-session.h Mon Sep 12 14:43:31 2011 +0300
@@ -16,6 +16,8 @@
int mail_session_lookup(const char *guid, struct mail_session **session_r,
const char **error_r);
+int mail_session_get(const char *guid, struct mail_session **session_r,
+ const char **error_r);
void mail_session_refresh(struct mail_session *session,
const struct mail_stats *diff_stats);
More information about the dovecot-cvs
mailing list