Fix: Handle exception during sol activate cmd
When there is any exception during StartConsole, the console must be
freed,without which it was wrongly assumeed that console is active.
Tested :
1.Disable SSH using systemctl stop obmc-console@xxx.service and
systemctl stop obmc-console@xxx.socket.
2.Activate sol multiple times. It should always give unspecified error
as response
Signed-off-by: Rashmi RV <rashmi.r.v@linux.intel.com>
Change-Id: Ia5b1e0686331a9a2c6c90383472030513adf1226
diff --git a/sol/sol_manager.cpp b/sol/sol_manager.cpp
index 2046fe4..3db7313 100644
--- a/sol/sol_manager.cpp
+++ b/sol/sol_manager.cpp
@@ -82,7 +82,7 @@
startHostConsole();
}
});
-}
+} // namespace sol
void Manager::stopHostConsole()
{
@@ -98,7 +98,18 @@
{
if (payloadMap.empty())
{
- startHostConsole();
+ try
+ {
+ startHostConsole();
+ }
+ catch (const std::exception& e)
+ {
+ log<level::ERR>("Encountered exception when starting host console. "
+ "Hence stopping host console.",
+ entry("EXCEPTION=%s", e.what()));
+ stopHostConsole();
+ throw;
+ }
}
// Create the SOL Context data for payload instance