From 87d4ad5b3f6893871d3048d1a9f8077d4f7b1cdf Mon Sep 17 00:00:00 2001
From: Roman Tokarev <rtokarev@corp.mail.ru>
Date: Thu, 7 Apr 2011 15:49:16 +0400
Subject: [PATCH] Add stat_cleanup.

mod/box:

Call stat_cleanup after recovery finished.
Fix stat_collect invocation.
---
 core/stat.m    | 8 ++++++++
 include/stat.h | 1 +
 mod/box/box.m  | 3 ++-
 3 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/core/stat.m b/core/stat.m
index 9ca48d52e0..343757009d 100644
--- a/core/stat.m
+++ b/core/stat.m
@@ -130,3 +130,11 @@ stat_init(void)
 	timer.repeat = 1.;
 	ev_timer_again(&timer);
 }
+
+void
+stat_cleanup(int base, size_t max_idx)
+{
+	for (int i = base; i < max_idx; i++)
+		for (int j = 0; j < SECS + 1; j++)
+			stats[i].value[j] = 0;
+}
diff --git a/include/stat.h b/include/stat.h
index 5fb30612ff..0549a2e0f5 100644
--- a/include/stat.h
+++ b/include/stat.h
@@ -29,6 +29,7 @@
 #include <tbuf.h>
 
 void stat_init(void);
+void stat_cleanup(int base, size_t max_idx);
 int stat_register(char **name, size_t count);
 void stat_collect(int base, int name, i64 value);
 void stat_print(struct tbuf *buf);
diff --git a/mod/box/box.m b/mod/box/box.m
index d044c84d10..350d80b697 100644
--- a/mod/box/box.m
+++ b/mod/box/box.m
@@ -1201,7 +1201,7 @@ box_process(struct box_txn *txn, u32 op, struct tbuf *request_data)
 {
 	ev_tstamp start = ev_now(), stop;
 
-	stat_collect(stat_base, txn->op, 1);
+	stat_collect(stat_base, op, 1);
 
 	@try {
 		txn_begin(txn, op, request_data);
@@ -1452,6 +1452,7 @@ mod_init(void)
 		return;
 
 	recover(recovery_state, 0);
+	stat_cleanup(stat_base, messages_MAX);
 
 	title("build_indexes");
 
-- 
GitLab