summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.clang-tidy1
-rw-r--r--include/dbus_monitor.hpp13
-rw-r--r--include/openbmc_dbus_rest.hpp10
-rw-r--r--redfish-core/lib/managers.hpp15
-rw-r--r--src/webserver_main.cpp15
5 files changed, 48 insertions, 6 deletions
diff --git a/.clang-tidy b/.clang-tidy
index db950cbf1c..3e9d87b2fb 100644
--- a/.clang-tidy
+++ b/.clang-tidy
@@ -8,6 +8,7 @@ bugprone-branch-clone,
bugprone-copy-constructor-init,
bugprone-dangling-handle,
bugprone-dynamic-static-initializers,
+bugprone-exception-escape,
bugprone-fold-init-type,
bugprone-forward-declaration-namespace,
bugprone-forwarding-reference-overload,
diff --git a/include/dbus_monitor.hpp b/include/dbus_monitor.hpp
index a6c86c61ef..c8e46b79c9 100644
--- a/include/dbus_monitor.hpp
+++ b/include/dbus_monitor.hpp
@@ -19,7 +19,9 @@ namespace dbus_monitor
struct DbusWebsocketSession
{
std::vector<std::unique_ptr<sdbusplus::bus::match::match>> matches;
- boost::container::flat_set<std::string> interfaces;
+ boost::container::flat_set<std::string, std::less<>,
+ std::vector<std::string>>
+ interfaces;
};
static boost::container::flat_map<crow::websocket::Connection*,
@@ -110,14 +112,19 @@ inline void requestRoutes(App& app)
.onopen([&](crow::websocket::Connection& conn,
const std::shared_ptr<bmcweb::AsyncResp>&) {
BMCWEB_LOG_DEBUG << "Connection " << &conn << " opened";
- sessions[&conn] = DbusWebsocketSession();
+ sessions.try_emplace(&conn);
})
.onclose([&](crow::websocket::Connection& conn, const std::string&) {
sessions.erase(&conn);
})
.onmessage([&](crow::websocket::Connection& conn,
const std::string& data, bool) {
- DbusWebsocketSession& thisSession = sessions[&conn];
+ const auto sessionPair = sessions.find(&conn);
+ if (sessionPair == sessions.end())
+ {
+ conn.close("Internal error");
+ }
+ DbusWebsocketSession& thisSession = sessionPair->second;
BMCWEB_LOG_DEBUG << "Connection " << &conn << " received " << data;
nlohmann::json j = nlohmann::json::parse(data, nullptr, false);
if (j.is_discarded())
diff --git a/include/openbmc_dbus_rest.hpp b/include/openbmc_dbus_rest.hpp
index 09bbd601a1..7f16ea8f6a 100644
--- a/include/openbmc_dbus_rest.hpp
+++ b/include/openbmc_dbus_rest.hpp
@@ -227,7 +227,15 @@ struct InProgressEnumerateData
~InProgressEnumerateData()
{
- findRemainingObjectsForEnumerate(objectPath, subtree, asyncResp);
+ try
+ {
+ findRemainingObjectsForEnumerate(objectPath, subtree, asyncResp);
+ }
+ catch (...)
+ {
+ BMCWEB_LOG_CRITICAL
+ << "findRemainingObjectsForEnumerate threw exception";
+ }
}
const std::string objectPath;
diff --git a/redfish-core/lib/managers.hpp b/redfish-core/lib/managers.hpp
index a48fd7715c..3a955cb355 100644
--- a/redfish-core/lib/managers.hpp
+++ b/redfish-core/lib/managers.hpp
@@ -1480,7 +1480,7 @@ struct SetPIDValues : std::enable_shared_from_this<SetPIDValues>
"xyz.openbmc_project.ObjectMapper", "GetSubTree", "/", 0,
std::array<const char*, 1>{thermalModeIface});
}
- ~SetPIDValues()
+ void pidSetDone()
{
if (asyncResp->res.result() != boost::beast::http::status::ok)
{
@@ -1683,6 +1683,19 @@ struct SetPIDValues : std::enable_shared_from_this<SetPIDValues>
}
}
}
+
+ ~SetPIDValues()
+ {
+ try
+ {
+ pidSetDone();
+ }
+ catch (...)
+ {
+ BMCWEB_LOG_CRITICAL << "pidSetDone threw exception";
+ }
+ }
+
std::shared_ptr<bmcweb::AsyncResp> asyncResp;
std::vector<std::pair<std::string, std::optional<nlohmann::json>>>
configuration;
diff --git a/src/webserver_main.cpp b/src/webserver_main.cpp
index bf98aae73b..b613008360 100644
--- a/src/webserver_main.cpp
+++ b/src/webserver_main.cpp
@@ -61,7 +61,7 @@ inline void setupSocket(crow::App& app)
}
}
-int main(int /*argc*/, char** /*argv*/)
+int run()
{
crow::Logger::setLogLevel(crow::LogLevel::Debug);
@@ -146,3 +146,16 @@ int main(int /*argc*/, char** /*argv*/)
crow::connections::systemBus.reset();
return 0;
}
+
+int main(int /*argc*/, char** /*argv*/)
+{
+ try
+ {
+ return run();
+ }
+ catch (...)
+ {
+ return -1;
+ BMCWEB_LOG_CRITICAL << "Threw exception to main";
+ }
+}