Add priority for oemcommands and fix
Added priority for global variable in oemcommand handler for oemData.
Closed oem data file after access.
Change-Id: I82f81733c18a2a81a76dfec286659939864876fb
Signed-off-by: Vijay Khemka <vijaykhemka@fb.com>
diff --git a/src/oemcommands.cpp b/src/oemcommands.cpp
index 782ab2b..cc3a604 100644
--- a/src/oemcommands.cpp
+++ b/src/oemcommands.cpp
@@ -51,7 +51,7 @@
ipmi_ret_t plat_udbg_control_panel(uint8_t, uint8_t, uint8_t, uint8_t *,
uint8_t *);
namespace variant_ns = sdbusplus::message::variant_ns;
-nlohmann::json oemData;
+nlohmann::json oemData __attribute__((init_priority(101)));
enum class LanParam : uint8_t
{
@@ -132,6 +132,7 @@
{
std::ofstream file(JSON_OEM_DATA_FILE);
file << oemData;
+ file.close();
return;
}
@@ -1537,7 +1538,10 @@
/* Get OEM data from json file */
std::ifstream file(JSON_OEM_DATA_FILE);
if (file)
+ {
file >> oemData;
+ file.close();
+ }
phosphor::logging::log<phosphor::logging::level::INFO>(
"Registering OEM commands");