Prevent multiple instances of trunksd from running.
DBus::Connection::request_name() does not indicate whether it
successfully acquires the requested DBus name or not (chromium:364585).
This CL changes trunksd to use newly introduced
DBus::Connection::acquire_name() (CL:195002) to ensure that trunksd can
successfully acquire its DBus name.
BUG=None
TEST=Build and run unit tests.
Change-Id: I295479d183bd59a835024201f5fd04d0f57e1b5d
Reviewed-on: https://chromium-review.googlesource.com/201242
Tested-by: Ben Chan <benchan@chromium.org>
Commit-Queue: Ben Chan <benchan@chromium.org>
Reviewed-by: mukesh agrawal <quiche@chromium.org>
diff --git a/tss/trunksd.cc b/tss/trunksd.cc
index d76edd5..4bd969c 100644
--- a/tss/trunksd.cc
+++ b/tss/trunksd.cc
@@ -27,7 +27,8 @@
// Setup the trunks dbus service.
DBus::Connection connection(DBus::Connection::SystemBus());
- connection.request_name(trunks::kTrunksDbusServiceName);
+ CHECK(connection.acquire_name(trunks::kTrunksDbusServiceName))
+ << "Failed to acquire DBus name: " << trunks::kTrunksDbusServiceName;
trunks::TrunksDbusService service(connection,
DBus::Path(trunks::kTrunksDbusServicePath));