dovecot-2.0: anvil: Added PENALTY-DUMP command to dump penalty s...

dovecot at dovecot.org dovecot at dovecot.org
Sat Feb 20 09:46:47 EET 2010


details:   http://hg.dovecot.org/dovecot-2.0/rev/1282d027ce67
changeset: 10779:1282d027ce67
user:      Timo Sirainen <tss at iki.fi>
date:      Sat Feb 20 09:32:48 2010 +0200
description:
anvil: Added PENALTY-DUMP command to dump penalty state.

diffstat:

 src/anvil/anvil-connection.c |   2 ++
 src/anvil/penalty.c          |  20 ++++++++++++++++++++
 src/anvil/penalty.h          |   1 +
 3 files changed, 23 insertions(+), 0 deletions(-)

diffs (57 lines):

diff -r 3f2d9da0c6bc -r 1282d027ce67 src/anvil/anvil-connection.c
--- a/src/anvil/anvil-connection.c	Sat Feb 20 09:32:13 2010 +0200
+++ b/src/anvil/anvil-connection.c	Sat Feb 20 09:32:48 2010 +0200
@@ -119,6 +119,8 @@
 			return -1;
 		}
 		penalty_set_expire_secs(penalty, atoi(args[0]));
+	} else if (strcmp(cmd, "PENALTY-DUMP") == 0) {
+		penalty_dump(penalty, conn->output);
 	} else {
 		*error_r = t_strconcat("Unknown command: ", cmd, NULL);
 		return -1;
diff -r 3f2d9da0c6bc -r 1282d027ce67 src/anvil/penalty.c
--- a/src/anvil/penalty.c	Sat Feb 20 09:32:13 2010 +0200
+++ b/src/anvil/penalty.c	Sat Feb 20 09:32:48 2010 +0200
@@ -3,7 +3,10 @@
 #include "lib.h"
 #include "ioloop.h"
 #include "hash.h"
+#include "str.h"
+#include "strescape.h"
 #include "llist.h"
+#include "ostream.h"
 #include "penalty.h"
 
 #include <time.h>
@@ -252,3 +255,20 @@
 	}
 	return FALSE;
 }
+
+void penalty_dump(struct penalty *penalty, struct ostream *output)
+{
+	const struct penalty_rec *rec;
+	string_t *str = t_str_new(256);
+
+	for (rec = penalty->oldest; rec != NULL; rec = rec->next) {
+		str_truncate(str, 0);
+		str_tabescape_write(str, rec->ident);
+		str_printfa(str, "\t%u\t%u\t%u\n",
+			    rec->penalty, rec->last_penalty,
+			    rec->last_penalty + rec->last_update);
+		if (o_stream_send(output, str_data(str), str_len(str)) < 0)
+			break;
+	}
+	(void)o_stream_send(output, "\n", 1);
+}
diff -r 3f2d9da0c6bc -r 1282d027ce67 src/anvil/penalty.h
--- a/src/anvil/penalty.h	Sat Feb 20 09:32:13 2010 +0200
+++ b/src/anvil/penalty.h	Sat Feb 20 09:32:48 2010 +0200
@@ -17,5 +17,6 @@
 
 bool penalty_has_checksum(struct penalty *penalty, const char *ident,
 			  unsigned int checksum);
+void penalty_dump(struct penalty *penalty, struct ostream *output);
 
 #endif


More information about the dovecot-cvs mailing list