Delay return from updateUbootEnvVars() until service file finishes

This commit, as the title might suggest, delays the return from the
function updateUbootEnvVars() until the called service file completes
running. The reason for this change is because the service file runs
asynchronously, so activation seemingly finishes before the priorities
are actually changed.

This is accomplished by adding a generic function waitForServiceFile()
which waits until the completion of a supplied one-shot service file or
until a timeout is reached.

Resolves openbmc/openbmc#2857

Change-Id: I7c0333f510f8239a0b66cc5a20159c91aa2dbdee
Signed-off-by: Michael Tritz <mtritz@us.ibm.com>
Signed-off-by: Saqib Khan <khansa@us.ibm.com>
diff --git a/item_updater.cpp b/item_updater.cpp
index df73fc5..a4198ab 100644
--- a/item_updater.cpp
+++ b/item_updater.cpp
@@ -575,6 +575,10 @@
         log<level::ERR>("Failed to update u-boot env variables",
                         entry("VERSIONID=%s", versionId.c_str()));
     }
+
+    // On average this service takes about 5 seconds. Therefore setting
+    // it to 3x average time should be more than sufficient.
+    waitForServiceFile(updateEnvVarsFile, 15);
 }
 
 void ItemUpdater::resetUbootEnvVars()