From 63393b70c3dc17afffa44f81801e21aa37ff0d4d Mon Sep 17 00:00:00 2001 From: Aki Tuomi Date: Mon, 11 Jan 2016 15:46:28 +0200 Subject: [PATCH] stats: Add RESET call to stats client --- src/stats/Makefile.am | 2 ++ src/stats/client-reset.c | 24 ++++++++++++++++++++++++ src/stats/client-reset.h | 9 +++++++++ src/stats/client.c | 2 ++ 4 files changed, 37 insertions(+) create mode 100644 src/stats/client-reset.c create mode 100644 src/stats/client-reset.h diff --git a/src/stats/Makefile.am b/src/stats/Makefile.am index 96ddcdcabd..e84ead1056 100644 --- a/src/stats/Makefile.am +++ b/src/stats/Makefile.am @@ -16,6 +16,7 @@ stats_DEPENDENCIES = $(LIBDOVECOT_DEPS) stats_SOURCES = \ client.c \ client-export.c \ + client-reset.c \ global-memory.c \ mail-command.c \ mail-domain.c \ @@ -30,6 +31,7 @@ stats_SOURCES = \ noinst_HEADERS = \ client.h \ client-export.h \ + client-reset.h \ global-memory.h \ mail-command.h \ mail-domain.h \ diff --git a/src/stats/client-reset.c b/src/stats/client-reset.c new file mode 100644 index 0000000000..d5a396771c --- /dev/null +++ b/src/stats/client-reset.c @@ -0,0 +1,24 @@ +/* Copyright (c) 2011-2015 Dovecot authors, see the included COPYING file */ + +#include "lib.h" +#include "net.h" +#include "ostream.h" +#include "str.h" +#include "strescape.h" +#include "mail-stats.h" +#include "mail-command.h" +#include "mail-session.h" +#include "mail-user.h" +#include "mail-domain.h" +#include "mail-ip.h" +#include "client.h" +#include "client-reset.h" + +int client_stats_reset(struct client *client, const char *const *args ATTR_UNUSED, + const char **error_r ATTR_UNUSED) +{ + struct mail_global *g = &mail_global_stats; + stats_reset(g->stats); + o_stream_nsend_str(client->output, "OK\n"); + return 0; +} diff --git a/src/stats/client-reset.h b/src/stats/client-reset.h new file mode 100644 index 0000000000..7a84d610ff --- /dev/null +++ b/src/stats/client-reset.h @@ -0,0 +1,9 @@ +#ifndef CLIENT_RESET_H +#define CLIENT_RESET_H + +struct client; + +int client_stats_reset(struct client *client, const char *const *args, + const char **error_r); + +#endif diff --git a/src/stats/client.c b/src/stats/client.c index bd2686c6d8..a69668ee4a 100644 --- a/src/stats/client.c +++ b/src/stats/client.c @@ -49,6 +49,8 @@ client_handle_request(struct client *client, const char *const *args, if (strcmp(cmd, "EXPORT") == 0) return client_export(client, args, error_r); + if (strcmp(cmd, "RESET") == 0) + return client_stats_reset(client, args, error_r); *error_r = "Unknown command"; return -1; -- 2.47.3