mmc: Remove: Sleep to allow service to finish

There's not currently a good solution for waiting for systemd
service files before returning from a function. The way to achieve
this is to add a sleep before returning.

Need to add a sleep for the mmc remove function to allow the device
to be erased before the update, otherwise the delete and update may
run at the same time causing corruption.

This race condition is not seeing in ubi because the update creates
a new volume for the image, while in the background the old volume
is being erased, although this could still cause issues if space is
tight and the delete is not finished by the time the new image is
written, but this issue hasn't been seen so focusing on mmc only
for this commit.

Tested: Verified no corruption was seen on the tacoma system where
        the issue was reported.

Change-Id: I89eeb97b357cc6a0eb0bf01aa9ac4147cab6168a
Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
diff --git a/mmc/item_updater_helper.cpp b/mmc/item_updater_helper.cpp
index 29b4e58..03036e9 100644
--- a/mmc/item_updater_helper.cpp
+++ b/mmc/item_updater_helper.cpp
@@ -38,6 +38,11 @@
     auto serviceFile = "obmc-flash-mmc-remove@" + versionId + ".service";
     method.append(serviceFile, "replace");
     bus.call_noreply(method);
+
+    // Wait a few seconds for the service file to finish, otherwise the BMC may
+    // start the update while the image is still being deleted.
+    constexpr auto removeWait = std::chrono::seconds(3);
+    std::this_thread::sleep_for(removeWait);
 }
 
 void Helper::updateUbootVersionId(const std::string& versionId)