summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRatan Gupta <ratagupt@in.ibm.com>2017-10-06 21:45:24 +0530
committerRatan Gupta <ratagupt@in.ibm.com>2018-02-23 20:05:18 +0530
commit8bbf9d2cc5a502fa0df0e70bd4232208a1ab6c01 (patch)
tree843f2eeafd07f8a7bb2505ea31495c729881c15e
parent3e84ec6645bcea669805947f1409b58b4b0d9f72 (diff)
downloadphosphor-dbus-monitor-8bbf9d2cc5a502fa0df0e70bd4232208a1ab6c01.tar.gz
phosphor-dbus-monitor-8bbf9d2cc5a502fa0df0e70bd4232208a1ab6c01.zip
Implement event rotating
Delete the oldest event of the same type if a particular type of event reaches threshold. Resolves openbmc/openbmc#2254 Change-Id: I2692193a027e82032f1d336515691de913bbb726 Signed-off-by: Ratan Gupta <ratagupt@in.ibm.com>
-rw-r--r--configure.ac4
-rw-r--r--src/event_manager.cpp7
2 files changed, 11 insertions, 0 deletions
diff --git a/configure.ac b/configure.ac
index 6bc253f..f5e8b3a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -66,5 +66,9 @@ AC_DEFINE_UNQUOTED([BUSNAME_EVENT], ["$BUSNAME_EVENT"], [The D-Bus busname to ow
AC_ARG_VAR(YAML_PATH, [The path to the yaml config files.])
AS_IF([test "x$YAML_PATH" == "x"], [YAML_PATH="\${top_srcdir}/src/example"])
+AC_ARG_VAR(MAX_EVENTS, [Maximum number of events.])
+AS_IF([test "x$MAX_EVENTS" == "x"], [MAX_EVENTS=20])
+AC_DEFINE_UNQUOTED([MAX_EVENTS], [$MAX_EVENTS], [Maximum number of events.])
+
AC_CONFIG_FILES([Makefile src/Makefile src/test/Makefile mslverify/Makefile])
AC_OUTPUT
diff --git a/src/event_manager.cpp b/src/event_manager.cpp
index 9102137..2c09f35 100644
--- a/src/event_manager.cpp
+++ b/src/event_manager.cpp
@@ -62,6 +62,13 @@ void Manager::create(
auto objPath = std::string(OBJ_EVENT) + '/' + eventName + '/' +
std::to_string(id);
+ // check for capping of the events,if cap reached then erase the oldest
+ // event.
+ if (eventQueue.size() == MAX_EVENTS)
+ {
+ eventQueue.pop();
+ }
+
eventQueue.emplace(std::make_unique<Entry>(
objPath,
ms, // Milliseconds since 1970
OpenPOWER on IntegriCloud