diff options
author | Agata Olender <agata.olender@intel.com> | 2020-01-13 15:31:49 +0300 |
---|---|---|
committer | Olender, Agata <agata.olender@intel.com> | 2020-01-29 13:36:50 +0300 |
commit | b9a4ef7fd96aeda3e311993810c68bbb6553f3c2 (patch) | |
tree | 592a97256535a1e95eed0f3682c5d4b2f948aed6 /src/configuration.hpp | |
parent | 332c885786635d2ab0d797105fee8e90400388c3 (diff) | |
download | virtual-media-b9a4ef7fd96aeda3e311993810c68bbb6553f3c2.tar.xz |
Gadget inactivity timeout
MountPoints being inactive for time defined by InactivityTimeout will be unmounted.
Inacitivity is measured based on USB gadget R/W statitics.
InactivityTimeout must be set in json configuration and is common for all MountPoints.
Remaining time to unmount inactive media is exposed per MountPoint on dbus using RemainingInactivityTimeout property.
Change-Id: Ieb80e67dae6c3b4cb0482d801b5b4208884b0809
Signed-off-by: Agata Olender <agata.olender@intel.com>
Diffstat (limited to 'src/configuration.hpp')
-rw-r--r-- | src/configuration.hpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/configuration.hpp b/src/configuration.hpp index dd71837..89c9d02 100644 --- a/src/configuration.hpp +++ b/src/configuration.hpp @@ -34,6 +34,7 @@ class Configuration std::string endPointId; std::optional<int> timeout; std::optional<int> blocksize; + std::chrono::seconds remainingInactivityTimeout; Mode mode; static std::vector<std::string> toArgs(const MountPoint& mp) @@ -59,6 +60,7 @@ class Configuration bool valid = false; boost::container::flat_map<std::string, MountPoint> mountPoints; + static std::chrono::seconds inactivityTimeout; Configuration(const std::string& file) { @@ -94,6 +96,13 @@ class Configuration bool setupVariables(const nlohmann::json& config) { + inactivityTimeout = + std::chrono::seconds(config.value("InactivityTimeout", 0)); + if (inactivityTimeout == std::chrono::seconds(0)) + { + LogMsg(Logger::Error, "InactivityTimeout required, not set"); + } + for (const auto& item : config.items()) { if (item.key() == "MountPoints") |