From 7fc52c8fe3bc7cc9b57a007ce1b7c38e60f9602f Mon Sep 17 00:00:00 2001 From: Kun Yi Date: Tue, 19 Nov 2019 13:45:05 -0800 Subject: 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 Change-Id: Ic781d54173099bff76b3c37dd296521680fe7986 --- manager.hpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'manager.hpp') 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 +#include #include #include #include @@ -35,6 +36,12 @@ struct SessionInfo 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 lastActionTime = + std::chrono::steady_clock::now(); }; class ManagerInterface @@ -249,6 +256,7 @@ class BlobManager : public ManagerInterface 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; -- cgit v1.2.3