From ff975efb2e88dcd5221a2f0d76c4c87e85b821a8 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 22 Jan 2014 23:36:06 +0100 Subject: bus: when we cannot bus activate a service because we go down, drop one message from the queue --- src/core/busname.c | 2 +- src/libsystemd/sd-bus/bus-kernel.c | 13 +++++++++++++ src/libsystemd/sd-bus/bus-kernel.h | 2 ++ 3 files changed, 16 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/core/busname.c b/src/core/busname.c index 9b6bf07d9f..0d19311db1 100644 --- a/src/core/busname.c +++ b/src/core/busname.c @@ -337,8 +337,8 @@ static void busname_enter_running(BusName *n) { log_debug_unit(UNIT(n)->id, "Suppressing activation request on %s since unit stop is scheduled.", UNIT(n)->id); /* Flush all queued activation reqeuest by closing and reopening the connection */ + bus_kernel_drop_one(n->starter_fd); - busname_close_fd(n); busname_enter_listening(n); return; } diff --git a/src/libsystemd/sd-bus/bus-kernel.c b/src/libsystemd/sd-bus/bus-kernel.c index a33e7a323c..b46cada648 100644 --- a/src/libsystemd/sd-bus/bus-kernel.c +++ b/src/libsystemd/sd-bus/bus-kernel.c @@ -1476,3 +1476,16 @@ int bus_kernel_try_close(sd_bus *bus) { return 0; } + +int bus_kernel_drop_one(int fd) { + struct kdbus_cmd_recv recv = { + .flags = KDBUS_RECV_DROP + }; + + assert(fd >= 0); + + if (ioctl(fd, KDBUS_CMD_MSG_RECV, &recv) < 0) + return -errno; + + return 0; +} diff --git a/src/libsystemd/sd-bus/bus-kernel.h b/src/libsystemd/sd-bus/bus-kernel.h index e9f776d9fd..de02b84f88 100644 --- a/src/libsystemd/sd-bus/bus-kernel.h +++ b/src/libsystemd/sd-bus/bus-kernel.h @@ -79,3 +79,5 @@ int kdbus_translate_request_name_flags(uint64_t sd_bus_flags, uint64_t *kdbus_fl int kdbus_translate_attach_flags(uint64_t sd_bus_flags, uint64_t *kdbus_flags); int bus_kernel_try_close(sd_bus *bus); + +int bus_kernel_drop_one(int fd); -- cgit v1.2.3-54-g00ecf