dovecot-2.0-sslstream: anvil: Added CONNECT-DUMP command to dump...

dovecot at dovecot.org dovecot at dovecot.org
Sat Feb 13 02:55:27 EET 2010


details:   http://hg.dovecot.org/dovecot-2.0-sslstream/rev/1110edddec36
changeset: 10146:1110edddec36
user:      Timo Sirainen <tss at iki.fi>
date:      Thu Oct 22 20:28:46 2009 -0400
description:
anvil: Added CONNECT-DUMP command to dump connect-limit state.

diffstat:

3 files changed, 27 insertions(+)
src/anvil/anvil-connection.c |    3 +++
src/anvil/connect-limit.c    |   23 +++++++++++++++++++++++
src/anvil/connect-limit.h    |    1 +

diffs (60 lines):

diff -r 19e67ad17398 -r 1110edddec36 src/anvil/anvil-connection.c
--- 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
@@ -65,6 +65,9 @@ anvil_connection_request(struct anvil_co
 		}
 		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) {
diff -r 19e67ad17398 -r 1110edddec36 src/anvil/connect-limit.c
--- 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 @@ void connect_limit_disconnect_pid(struct
 	}
 	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);
+}
diff -r 19e67ad17398 -r 1110edddec36 src/anvil/connect-limit.h
--- 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 con
 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


More information about the dovecot-cvs mailing list