dovecot-2.2-pigeonhole: managesieve: Implemented support for rep...

pigeonhole at rename-it.nl pigeonhole at rename-it.nl
Wed May 13 17:53:16 UTC 2015


details:   http://hg.rename-it.nl/dovecot-2.2-pigeonhole/rev/ff3ab88205a6
changeset: 2064:ff3ab88205a6
user:      Stephan Bosch <stephan at rename-it.nl>
date:      Wed May 13 19:52:51 2015 +0200
description:
managesieve: Implemented support for reporting command statistics at disconnect.

diffstat:

 src/managesieve/cmd-deletescript.c   |   1 +
 src/managesieve/cmd-getscript.c      |   3 +++
 src/managesieve/cmd-putscript.c      |   8 ++++++++
 src/managesieve/cmd-renamescript.c   |   6 ++++--
 src/managesieve/managesieve-client.c |  22 +++++++++++++++++++---
 src/managesieve/managesieve-client.h |   9 +++++++++
 6 files changed, 44 insertions(+), 5 deletions(-)

diffs (118 lines):

diff -r 555374414869 -r ff3ab88205a6 src/managesieve/cmd-deletescript.c
--- a/src/managesieve/cmd-deletescript.c	Wed May 13 19:52:51 2015 +0200
+++ b/src/managesieve/cmd-deletescript.c	Wed May 13 19:52:51 2015 +0200
@@ -31,6 +31,7 @@
 	if ( sieve_script_delete(script, FALSE) < 0 ) {
 		client_send_storage_error(client, storage);
 	} else {
+		client->deleted_count++;
 		client_send_ok(client, "Deletescript completed.");
 	}
 
diff -r 555374414869 -r ff3ab88205a6 src/managesieve/cmd-getscript.c
--- a/src/managesieve/cmd-getscript.c	Wed May 13 19:52:51 2015 +0200
+++ b/src/managesieve/cmd-getscript.c	Wed May 13 19:52:51 2015 +0200
@@ -40,6 +40,9 @@
 		return TRUE;
 	}
 
+	client->get_count++;
+	client->get_bytes += ctx->script_size;
+
 	client_send_line(client, "");
 	client_send_ok(client, "Getscript completed.");
 	return TRUE;
diff -r 555374414869 -r ff3ab88205a6 src/managesieve/cmd-putscript.c
--- a/src/managesieve/cmd-putscript.c	Wed May 13 19:52:51 2015 +0200
+++ b/src/managesieve/cmd-putscript.c	Wed May 13 19:52:51 2015 +0200
@@ -249,6 +249,14 @@
 
 			/* Report result to user */
 			if ( success ) {
+				if ( ctx->scriptname != NULL ) {
+					client->put_count++;
+					client->put_bytes += ctx->script_size;
+				} else {
+					client->check_count++;
+					client->check_bytes += ctx->script_size;
+				}
+
 				if ( sieve_get_warnings(ehandler) > 0 )
 					client_send_okresp(client, "WARNINGS", str_c(errors));
 				else {
diff -r 555374414869 -r ff3ab88205a6 src/managesieve/cmd-renamescript.c
--- a/src/managesieve/cmd-renamescript.c	Wed May 13 19:52:51 2015 +0200
+++ b/src/managesieve/cmd-renamescript.c	Wed May 13 19:52:51 2015 +0200
@@ -29,10 +29,12 @@
 		return TRUE;
 	}
 
-	if (sieve_script_rename(script, newname) < 0)
+	if (sieve_script_rename(script, newname) < 0) {
 		client_send_storage_error(client, storage);
-	else
+	} else {
+		client->renamed_count++;
 		client_send_ok(client, "Renamescript completed.");
+	}
 
 	sieve_script_unref(&script);
 	return TRUE;
diff -r 555374414869 -r ff3ab88205a6 src/managesieve/managesieve-client.c
--- a/src/managesieve/managesieve-client.c	Wed May 13 19:52:51 2015 +0200
+++ b/src/managesieve/managesieve-client.c	Wed May 13 19:52:51 2015 +0200
@@ -175,6 +175,14 @@
 static const char *client_stats(struct client *client)
 {
 	static struct var_expand_table static_tab[] = {
+		{ 't', NULL, "put_bytes" },
+		{ 'p', NULL, "put_count" },
+		{ 'b', NULL, "get_bytes" },
+		{ 'g', NULL, "get_count" },
+		{ 'v', NULL, "check_bytes" },
+		{ 'c', NULL, "check_count" },
+		{ 'd', NULL, "deleted_count" },
+		{ 'r', NULL, "renamed_count" },
 		{ 'i', NULL, "input" },
 		{ 'o', NULL, "output" },
 		{ '\0', NULL, "session" },
@@ -186,9 +194,17 @@
 	tab = t_malloc(sizeof(static_tab));
 	memcpy(tab, static_tab, sizeof(static_tab));
 
-	tab[0].value = dec2str(i_stream_get_absolute_offset(client->input));
-	tab[1].value = dec2str(client->output->offset);
-	tab[2].value = client->session_id;
+	tab[0].value = dec2str(client->put_bytes);
+	tab[1].value = dec2str(client->put_count);
+	tab[2].value = dec2str(client->get_bytes);
+	tab[3].value = dec2str(client->get_count);
+	tab[4].value = dec2str(client->check_bytes);
+	tab[5].value = dec2str(client->check_count);
+	tab[6].value = dec2str(client->deleted_count);
+	tab[7].value = dec2str(client->renamed_count);
+	tab[8].value = dec2str(i_stream_get_absolute_offset(client->input));
+	tab[9].value = dec2str(client->output->offset);
+	tab[10].value = client->session_id;
 
 	str = t_str_new(128);
 	var_expand(str, client->set->managesieve_logout_format, tab);
diff -r 555374414869 -r ff3ab88205a6 src/managesieve/managesieve-client.h
--- a/src/managesieve/managesieve-client.h	Wed May 13 19:52:51 2015 +0200
+++ b/src/managesieve/managesieve-client.h	Wed May 13 19:52:51 2015 +0200
@@ -57,6 +57,15 @@
 	struct managesieve_parser *parser;
 	struct client_command_context cmd;
 
+	uoff_t put_bytes;
+	uoff_t get_bytes;
+	uoff_t check_bytes;
+	unsigned int put_count;
+	unsigned int get_count;
+	unsigned int check_count;
+	unsigned int deleted_count;
+	unsigned int renamed_count;
+
 	unsigned int disconnected:1;
 	unsigned int destroyed:1;
 	unsigned int command_pending:1;


More information about the dovecot-cvs mailing list