bmcdump: ignore dump request when a dump is in progress

At present generating a user dump is an asynchronous call
and does not block the user to generate another dump.

This can cause out-of-memory issues if dumps are
generated in a loop.

Adding a check to see if the user-initiated dump is
already in progress before starting another user
dump request.

Return "Unavailable" error if generate user dump request is
received while a user dump generation is in progress.

Tested:
'''
root@p10bmc:~# busctl --verbose call xyz.openbmc_project.Dump.Manager
/xyz/openbmc_project/dump/bmc xyz.openbmc_project.Dump.Create CreateDump a{sv} 0
MESSAGE "o" {
        OBJECT_PATH "/xyz/openbmc_project/dump/bmc/entry/3";
};

root@p10bmc:~# busctl --verbose call xyz.openbmc_project.Dump.Manager
/xyz/openbmc_project/dump/bmc xyz.openbmc_project.Dump.Create CreateDump a{sv} 0
Call failed: The operation is not allowed
root@p10bmc:~# busctl --verbose call xyz.openbmc_project.Dump.Manager
/xyz/openbmc_project/dump/bmc xyz.openbmc_project.Dump.Create CreateDump a{sv} 0
Call failed: The operation is not allowed
root@p10bmc:~# busctl --verbose call xyz.openbmc_project.Dump.Manager
/xyz/openbmc_project/dump/bmc xyz.openbmc_project.Dump.Create CreateDump a{sv} 0
MESSAGE "o" {
        OBJECT_PATH "/xyz/openbmc_project/dump/bmc/entry/4";
};

'''

Signed-off-by: Marri Devender Rao <devenrao@in.ibm.com>
Change-Id: Ic9434f34c040405f8664f7dc71109e7cb67a80c2
diff --git a/dump_manager_bmc.hpp b/dump_manager_bmc.hpp
index 6c1910f..9297f6e 100644
--- a/dump_manager_bmc.hpp
+++ b/dump_manager_bmc.hpp
@@ -8,7 +8,6 @@
 #include <xyz/openbmc_project/Dump/Create/server.hpp>
 
 #include <filesystem>
-
 namespace phosphor
 {
 namespace dump
@@ -119,10 +118,14 @@
      *
      *  @returns 0 on success, -1 on fail
      */
-    static int callback(sd_event_source*, const siginfo_t*, void*)
+    static int callback(sd_event_source*, const siginfo_t*, void* type)
     {
-        // No specific action required in
-        // the sd_event_add_child callback.
+        Type* ptr = reinterpret_cast<Type*>(type);
+        if (*ptr == Type::UserRequested)
+        {
+            fUserDumpInProgress = false;
+        }
+        delete ptr;
         return 0;
     }
     /** @brief Remove specified watch object pointer from the
@@ -146,6 +149,10 @@
     /** @brief Path to the dump file*/
     std::string dumpDir;
 
+    /** @brief Flag to reject user intiated dump if a dump is in progress*/
+    // TODO: https://github.com/openbmc/phosphor-debug-collector/issues/19
+    static bool fUserDumpInProgress;
+
     /** @brief Child directory path and its associated watch object map
      *        [path:watch object]
      */