diff options
author | Adriana Kobylak <anoo@us.ibm.com> | 2018-02-28 15:48:48 -0600 |
---|---|---|
committer | Gunnar Mills <gmills@us.ibm.com> | 2018-03-01 14:50:09 +0000 |
commit | 83cd21fbab1a59f57c4a8752406478a0127bde21 (patch) | |
tree | c6c54e9b498fd245197edb55794a8255f8725411 | |
parent | f9ae45d2f300349bd8d5c8947f16fceb107b602e (diff) | |
download | phosphor-bmc-code-mgmt-83cd21fbab1a59f57c4a8752406478a0127bde21.tar.gz phosphor-bmc-code-mgmt-83cd21fbab1a59f57c4a8752406478a0127bde21.zip |
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>
-rw-r--r-- | item_updater.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
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::erase(std::string entryId) 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, |