]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
anvil: Added PENALTY-DUMP command to dump penalty state.
authorTimo Sirainen <tss@iki.fi>
Sat, 20 Feb 2010 07:32:48 +0000 (09:32 +0200)
committerTimo Sirainen <tss@iki.fi>
Sat, 20 Feb 2010 07:32:48 +0000 (09:32 +0200)
--HG--
branch : HEAD

src/anvil/anvil-connection.c
src/anvil/penalty.c
src/anvil/penalty.h

index 915e0053287e1330b2706ea026d1eb0a5a0792d5..42d05a351ea72212980383ed64c7e3457c2c1309 100644 (file)
@@ -119,6 +119,8 @@ anvil_connection_request(struct anvil_connection *conn,
                        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;
index f258b00e88fbbe27a3e8531f1a4844fd857f2b05..3284f58148b57870ffc9cced2f5824804aea9ed9 100644 (file)
@@ -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 @@ bool penalty_has_checksum(struct penalty *penalty, const char *ident,
        }
        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);
+}
index b765907c7231dfe4516caf17d09b8a46af95907d..23a182cde49c626fefd8625d9f715883d31731a9 100644 (file)
@@ -17,5 +17,6 @@ void penalty_inc(struct penalty *penalty, const char *ident,
 
 bool penalty_has_checksum(struct penalty *penalty, const char *ident,
                          unsigned int checksum);
+void penalty_dump(struct penalty *penalty, struct ostream *output);
 
 #endif