summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarol Wachowski <karol.wachowski@intel.com>2020-07-23 11:25:04 +0300
committerFeist, James <james.feist@intel.com>2020-07-24 02:06:44 +0300
commit05eb73ebe684b8d2879c3802029fd783bdf6686c (patch)
tree11c842b080d838e8e05ed165785db7f0add1826a
parent2428b6eed51e30a324148529eb6429a9d474f857 (diff)
downloadvirtual-media-05eb73ebe684b8d2879c3802029fd783bdf6686c.tar.xz
VirtualMedia throw EBUSY exception when receive invalid event in
actiavting/deactivating states Previously mount/unmount waited until timeout occurs, when operation was already process it could finish before the timeout causing mount/unmount to get false positive/negative results. Tested: - Mount/Unmount dbus calls cause EBUSY exception in actiavting/deactivating states Change-Id: Idaacde212531c963aec304ac87e536d014d9d8d2 Signed-off-by: Karol Wachowski <karol.wachowski@intel.com>
-rw-r--r--src/state/activating_state.hpp8
-rw-r--r--src/state/deactivating_state.hpp8
-rw-r--r--src/state/initial_state.hpp23
3 files changed, 8 insertions, 31 deletions
diff --git a/src/state/activating_state.hpp b/src/state/activating_state.hpp
index bd1688f..295d185 100644
--- a/src/state/activating_state.hpp
+++ b/src/state/activating_state.hpp
@@ -17,14 +17,12 @@ struct ActivatingState : public BasicStateT<ActivatingState>
std::unique_ptr<BasicState> handleEvent(SubprocessStoppedEvent event);
template <class AnyEvent>
- std::unique_ptr<BasicState> handleEvent(AnyEvent event)
- {
+ [[noreturn]] std::unique_ptr<BasicState> handleEvent(AnyEvent event) {
LogMsg(Logger::Error, "Invalid event: ", event.eventName);
- return nullptr;
+ throw sdbusplus::exception::SdBusError(EBUSY, "Resource is busy");
}
- private:
- std::unique_ptr<BasicState> activateProxyMode();
+ private : std::unique_ptr<BasicState> activateProxyMode();
std::unique_ptr<BasicState> activateLegacyMode();
std::unique_ptr<BasicState> mountSmbShare();
std::unique_ptr<BasicState> mountHttpsShare();
diff --git a/src/state/deactivating_state.hpp b/src/state/deactivating_state.hpp
index 7f3010a..0ad6f5b 100644
--- a/src/state/deactivating_state.hpp
+++ b/src/state/deactivating_state.hpp
@@ -49,14 +49,12 @@ struct DeactivatingState : public BasicStateT<DeactivatingState>
}
template <class AnyEvent>
- std::unique_ptr<BasicState> handleEvent(AnyEvent event)
- {
+ [[noreturn]] std::unique_ptr<BasicState> handleEvent(AnyEvent event) {
LogMsg(Logger::Error, "Invalid event: ", event.eventName);
- return nullptr;
+ throw sdbusplus::exception::SdBusError(EBUSY, "Resource is busy");
}
- private:
- std::unique_ptr<BasicState> evaluate()
+ private : std::unique_ptr<BasicState> evaluate()
{
if (udevStateChangeEvent && subprocessStoppedEvent)
{
diff --git a/src/state/initial_state.hpp b/src/state/initial_state.hpp
index fecf2b6..f64ff25 100644
--- a/src/state/initial_state.hpp
+++ b/src/state/initial_state.hpp
@@ -134,17 +134,7 @@ struct InitialState : public BasicStateT<InitialState>
timerPeriod](boost::asio::yield_context yield) {
LogMsg(Logger::Info, "[App]: Unmount called on ",
machine.getName());
-
- try
- {
- machine.emitUnmountEvent();
- }
- catch (const std::exception& e)
- {
- LogMsg(Logger::Error, e.what());
- throw sdbusplus::exception::SdBusError(EPERM, e.what());
- return false;
- }
+ machine.emitUnmountEvent();
auto repeats = waitCnt;
boost::asio::steady_timer timer(machine.getIoc());
@@ -174,16 +164,7 @@ struct InitialState : public BasicStateT<InitialState>
interfaces::MountPointStateMachine& machine,
std::optional<interfaces::MountPointStateMachine::Target>
target) {
- try
- {
- machine.emitMountEvent(std::move(target));
- }
- catch (const std::exception& e)
- {
- LogMsg(Logger::Error, e.what());
- throw sdbusplus::exception::SdBusError(EPERM, e.what());
- return false;
- }
+ machine.emitMountEvent(std::move(target));
auto repeats = waitCnt;
boost::asio::steady_timer timer(machine.getIoc());