item_updater: Fix DeleteAll
With the phosphor-bmc-code-mgmt commit ee13e8 "BMC: Fix the
delete implementation" it broke the DeleteAll implementation
created with commit bc1bf3a "BMC Updater: Add function to
delete all versions" by erasing elements from the container
we're iterating over, causing the application to core dump.
Putting the original implementation back.
Fixes openbmc/openbmc#2954
Change-Id: I858a2d773e6f529a6253903198048326d74d5c15
Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
diff --git a/item_updater.cpp b/item_updater.cpp
index 1596a4b..30e6b0a 100644
--- a/item_updater.cpp
+++ b/item_updater.cpp
@@ -351,14 +351,21 @@
void ItemUpdater::deleteAll()
{
+ std::vector<std::string> deletableVersions;
+
for (const auto& versionIt : versions)
{
if (!versionIt.second->isFunctional())
{
- ItemUpdater::erase(versionIt.first);
+ deletableVersions.push_back(versionIt.first);
}
}
+ for (const auto& deletableIt : deletableVersions)
+ {
+ ItemUpdater::erase(deletableIt);
+ }
+
// Remove any volumes that do not match current versions.
auto method = bus.new_method_call(
SYSTEMD_BUSNAME,