bios: Delete uploaded DBus object after update
When the BIOS code update is completed, delete the uploaded DBus object
so that only the "bios_active" object remains.
Otherwise it leaves the uploaded DBus object that does not reflect a
real thing.
Tested: Verify only bios_active remains and the uploaded BIOS object is
deleted from DBus, and it is possible to upload and update the
same BIOS tarball for multieple times.
Signed-off-by: Lei YU <yulei.sh@bytedance.com>
Change-Id: I18e76238821f48a3b322594bb359fcb37f28f397
diff --git a/item_updater_main.cpp b/item_updater_main.cpp
index 79c4fd8..7e41ad7 100644
--- a/item_updater_main.cpp
+++ b/item_updater_main.cpp
@@ -2,12 +2,20 @@
#include "item_updater.hpp"
+#include <boost/asio/io_context.hpp>
+#include <sdbusplus/asio/connection.hpp>
#include <sdbusplus/bus.hpp>
#include <sdbusplus/server/manager.hpp>
+boost::asio::io_context& getIOContext()
+{
+ static boost::asio::io_context io;
+ return io;
+}
+
int main()
{
- auto bus = sdbusplus::bus::new_default();
+ sdbusplus::asio::connection bus(getIOContext());
// Add sdbusplus ObjectManager.
sdbusplus::server::manager::manager objManager(bus, SOFTWARE_OBJPATH);
@@ -16,10 +24,7 @@
bus.request_name(BUSNAME_UPDATER);
- while (true)
- {
- bus.process_discard();
- bus.wait();
- }
+ getIOContext().run();
+
return 0;
}