Mercurial > dovecot > core-2.2
changeset 10145:1110edddec36 HEAD
anvil: Added CONNECT-DUMP command to dump connect-limit state.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Thu, 22 Oct 2009 20:28:46 -0400 |
parents | 19e67ad17398 |
children | b8df77326978 |
files | src/anvil/anvil-connection.c src/anvil/connect-limit.c src/anvil/connect-limit.h |
diffstat | 3 files changed, 27 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/src/anvil/anvil-connection.c Thu Oct 22 20:08:11 2009 -0400 +++ b/src/anvil/anvil-connection.c Thu Oct 22 20:28:46 2009 -0400 @@ -66,6 +66,9 @@ pid = strtol(args[0], NULL, 10); connect_limit_disconnect(connect_limit, pid, args[1]); return 0; + } else if (strcmp(cmd, "CONNECT-DUMP") == 0) { + connect_limit_dump(connect_limit, conn->output); + return 0; } else if (strcmp(cmd, "KILL") == 0) { if (args[0] == NULL) { *error_r = "KILL: Not enough parameters";
--- a/src/anvil/connect-limit.c Thu Oct 22 20:08:11 2009 -0400 +++ b/src/anvil/connect-limit.c Thu Oct 22 20:28:46 2009 -0400 @@ -2,6 +2,9 @@ #include "common.h" #include "hash.h" +#include "str.h" +#include "strescape.h" +#include "ostream.h" #include "connect-limit.h" struct ident_pid { @@ -164,3 +167,23 @@ } hash_table_iterate_deinit(&iter); } + +void connect_limit_dump(struct connect_limit *limit, struct ostream *output) +{ + struct hash_iterate_context *iter; + void *key, *value; + string_t *str = t_str_new(256); + + iter = hash_table_iterate_init(limit->ident_pid_hash); + while (hash_table_iterate(iter, &key, &value)) { + struct ident_pid *i = key; + + str_truncate(str, 0); + str_tabescape_write(str, i->ident); + str_printfa(str, "\t%ld\t%u\n", (long)i->pid, i->refcount); + if (o_stream_send(output, str_data(str), str_len(str)) < 0) + break; + } + hash_table_iterate_deinit(&iter); + (void)o_stream_send(output, "\n", 1); +}
--- a/src/anvil/connect-limit.h Thu Oct 22 20:08:11 2009 -0400 +++ b/src/anvil/connect-limit.h Thu Oct 22 20:28:46 2009 -0400 @@ -11,5 +11,6 @@ void connect_limit_disconnect(struct connect_limit *limit, pid_t pid, const char *ident); void connect_limit_disconnect_pid(struct connect_limit *limit, pid_t pid); +void connect_limit_dump(struct connect_limit *limit, struct ostream *output); #endif