Request name with default non-zero flags
Adds default flags to be used when calling sd_bus_request_name:
SD_BUS_NAME_ALLOW_REPLACEMENT and SD_BUS_NAME_REPLACE_EXISTING. This
fixes sporadical issue observed in one of our services, where, after its
restart with systemctl command, exception was thrown when calling
request_name(), with code "FileExists".
Tested:
Confirmed that exception no longer appears after service restart.
Change-Id: Iff4b96cd2ee36960daec2d9b2eb42abcf3b88159
Signed-off-by: Michal Orzel <michalx.orzel@intel.com>
diff --git a/include/sdbusplus/bus.hpp b/include/sdbusplus/bus.hpp
index 294db22..21dfaf9 100644
--- a/include/sdbusplus/bus.hpp
+++ b/include/sdbusplus/bus.hpp
@@ -232,7 +232,9 @@
*/
void request_name(const char* service)
{
- int r = _intf->sd_bus_request_name(_bus.get(), service, 0);
+ int r = _intf->sd_bus_request_name(
+ _bus.get(), service,
+ (SD_BUS_NAME_ALLOW_REPLACEMENT | SD_BUS_NAME_REPLACE_EXISTING));
if (r < 0)
{
throw exception::SdBusError(-r, "sd_bus_request_name");