|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
From 430e21c2f7e77d600257ead56419f511e48e854a Mon Sep 17 00:00:00 2001
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
From: Lennart Poettering <lennart@poettering.net>
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
Date: Thu, 21 Aug 2014 17:20:19 +0200
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
Subject: [PATCH] bus: when terminating our bus-actviated services that
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
exit-on-idle send STOPPING=1 via sd_notify()
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
This should fix a race where a service thatis idle drops its name, and
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
is immediately requested by another client, which causes dbus-daemon to
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
ask systemd to activate it again, but since systemd still assumes it is
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
running it won't do anything.
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
---
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
src/libsystemd/sd-bus/bus-util.c | 16 ++++++++++++----
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
1 file changed, 12 insertions(+), 4 deletions(-)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
diff --git a/src/libsystemd/sd-bus/bus-util.c b/src/libsystemd/sd-bus/bus-util.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
index 475ed34a53..c97bf7d99d 100644
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
--- a/src/libsystemd/sd-bus/bus-util.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+++ b/src/libsystemd/sd-bus/bus-util.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -22,6 +22,8 @@
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
#include <sys/socket.h>
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
#include <sys/capability.h>
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+#include "systemd/sd-daemon.h"
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
#include "util.h"
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
#include "strv.h"
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
#include "macro.h"
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -128,11 +130,17 @@ int bus_event_loop_with_idle(
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (r == -EBUSY)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
continue;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ /* Fallback for dbus1 connections: we
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ * unregister the name and wait for the
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ * response to come through for it */
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (r == -ENOTSUP) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- /* Fallback for dbus1 connections: we
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- * unregister the name and wait for
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- * the response to come through for
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- * it */
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ /* Inform the service manager that we
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ * are going down, so that it will
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ * queue all further start requests,
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ * instead of assuming we are already
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ * running. */
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ sd_notify(false, "STOPPING=1");
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
r = bus_async_unregister_and_exit(e, bus, name);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (r < 0)
|