diff options
author | Lennart Poettering <lennart@poettering.net> | 2013-12-20 23:25:43 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2013-12-20 23:26:11 +0100 |
commit | ae095f860593c87d217773976cfe5f89a6993c89 (patch) | |
tree | 5a014286ac5088e72e2044faa028962774ebcdf9 /src/libsystemd-bus/sd-bus.c | |
parent | 5a884f93fdb2a6f89605e44a0e7f4d2db5470b5b (diff) |
bus: wrap KDBUS_CMD_BYEBYE with a high-level call sd_bus_try_close()
Diffstat (limited to 'src/libsystemd-bus/sd-bus.c')
-rw-r--r-- | src/libsystemd-bus/sd-bus.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/libsystemd-bus/sd-bus.c b/src/libsystemd-bus/sd-bus.c index 9c564de764..a39495541b 100644 --- a/src/libsystemd-bus/sd-bus.c +++ b/src/libsystemd-bus/sd-bus.c @@ -2956,3 +2956,19 @@ _public_ int sd_bus_get_peer_creds(sd_bus *bus, uint64_t mask, sd_bus_creds **re *ret = c; return 0; } + +_public_ int sd_bus_try_close(sd_bus *bus) { + int r; + + assert_return(bus, -EINVAL); + assert_return(BUS_IS_OPEN(bus->state), -ENOTCONN); + assert_return(!bus_pid_changed(bus), -ECHILD); + assert_return(bus->is_kernel, -ENOTSUP); + + r = bus_kernel_try_close(bus); + if (r < 0) + return r; + + sd_bus_close(bus); + return 0; +} |