Add lock around callback

We found that the system.json was being updated
by 1 callback, but being read in another, was causing
EM to think it had already published some data on
d-bus that it hadn't. This fixes that issue.

Tested: 100+ AC Cycles were preformed, no corruption

Change-Id: Iceb0ca462494ff768dc662f59a2ee986060d3570
Signed-off-by: James Feist <james.feist@linux.intel.com>
diff --git a/src/EntityManager.cpp b/src/EntityManager.cpp
index af9a766..98f24b2 100644
--- a/src/EntityManager.cpp
+++ b/src/EntityManager.cpp
@@ -1716,6 +1716,7 @@
 void propertiesChangedCallback(nlohmann::json& systemConfiguration,
                                sdbusplus::asio::object_server& objServer)
 {
+    static bool inProgress = false;
     static boost::asio::steady_timer timer(io);
     static size_t instance = 0;
     instance++;
@@ -1737,6 +1738,13 @@
             return;
         }
 
+        if (inProgress)
+        {
+            propertiesChangedCallback(systemConfiguration, objServer);
+            return;
+        }
+        inProgress = true;
+
         nlohmann::json oldConfiguration = systemConfiguration;
         auto missingConfigurations = std::make_shared<nlohmann::json>();
         *missingConfigurations = systemConfiguration;
@@ -1745,6 +1753,7 @@
         if (!findJsonFiles(configurations))
         {
             std::cerr << "cannot find json files\n";
+            inProgress = false;
             return;
         }
 
@@ -1812,6 +1821,8 @@
                     logDeviceAdded(item.value());
                 }
 
+                inProgress = false;
+
                 io.post([&, newConfiguration]() {
                     loadOverlays(newConfiguration);