bmc: Rework abortProcess and deleteBlob
In order to ensure we can abortProcess upon deleteBlob during an active
update, removed the fileOpen() check and abortProcess clears the lookup
table.
Signed-off-by: Brandon Kim <brandonkim@google.com>
Change-Id: I1b6b0efcabb91b7866f83d034c06780b126953d0
diff --git a/bmc/firmware_handler.cpp b/bmc/firmware_handler.cpp
index 96b4eba..d58825e 100644
--- a/bmc/firmware_handler.cpp
+++ b/bmc/firmware_handler.cpp
@@ -101,21 +101,6 @@
*/
bool FirmwareBlobHandler::deleteBlob(const std::string& path)
{
- /* This cannot be called if you have an open session to the path.
- * You can have an open session to verify/update/hash/image, but not active*
- *
- * Therefore, if this is called, it's either on a blob that isn't presently
- * open. However, there could be open blobs, so we need to close all open
- * sessions. This closing on our is an invalid handler behavior. Therefore,
- * we cannot close an active session. To enforce this, we only allow
- * deleting if there isn't a file open.
- */
- if (fileOpen())
- {
- return false;
- }
-
- /* only includes states where fileOpen() == false */
switch (state)
{
case UpdateState::notYetStarted:
@@ -740,16 +725,18 @@
break;
}
- if (item->second->dataHandler)
+ if (!lookup.empty())
{
- item->second->dataHandler->close();
+ if (item->second->dataHandler)
+ {
+ item->second->dataHandler->close();
+ }
+ if (item->second->imageHandler)
+ {
+ item->second->imageHandler->close();
+ }
+ lookup.erase(item);
}
- if (item->second->imageHandler)
- {
- item->second->imageHandler->close();
- }
-
- lookup.erase(item);
return true;
}
@@ -803,6 +790,19 @@
removeBlobId(activeImageBlobId);
removeBlobId(activeHashBlobId);
+ for (auto item : lookup)
+ {
+ if (item.second->dataHandler)
+ {
+ item.second->dataHandler->close();
+ }
+ if (item.second->imageHandler)
+ {
+ item.second->imageHandler->close();
+ }
+ }
+ lookup.clear();
+
openedFirmwareType = "";
changeState(UpdateState::notYetStarted);
}