Store the last action time in session info
Add a timestamp member in SessionStat to capture when the session
sees activity last, and update it with every action. The timestamp
will be used to check when the session should expire.
Signed-off-by: Kun Yi <kunyi731@gmail.com>
Change-Id: Ic781d54173099bff76b3c37dd296521680fe7986
diff --git a/manager.hpp b/manager.hpp
index 1c04c6a..e7a9a97 100644
--- a/manager.hpp
+++ b/manager.hpp
@@ -1,6 +1,7 @@
#pragma once
#include <blobs-ipmid/blobs.hpp>
+#include <chrono>
#include <ctime>
#include <ipmid/oemrouter.hpp>
#include <memory>
@@ -35,6 +36,12 @@
std::string blobId;
GenericBlobInterface* handler;
uint16_t flags;
+
+ /* Initially set during open(). read/write/writeMeta/commit/stat operations
+ * would update it.
+ */
+ std::chrono::time_point<std::chrono::steady_clock> lastActionTime =
+ std::chrono::steady_clock::now();
};
class ManagerInterface
@@ -249,6 +256,7 @@
if (auto item = sessions.find(session);
item != sessions.end() && (item->second.flags & requiredFlags))
{
+ item->second.lastActionTime = std::chrono::steady_clock::now();
return item->second.handler;
}
return nullptr;