dcavalca / rpms / systemd

Forked from rpms/systemd 3 months ago
Clone
21255d
From 6a50c735a3bbf98d06fbfa7815f7bdc14ea96f9f Mon Sep 17 00:00:00 2001
21255d
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
21255d
Date: Wed, 14 Oct 2020 14:03:13 +0200
21255d
Subject: [PATCH] sd-bus: break the loop in bus_ensure_running() if the bus is
21255d
 not connecting
21255d
21255d
This might fix #17025:
21255d
> the call trace is
21255d
> bus_ensure_running -> sd_bus_process -> bus_process_internal -> process_closeing --> sd_bus_close
21255d
>                                                                                  |
21255d
>                                                                                  \-> process_match
21255d
21255d
We ended doing callouts to the Disconnected matches from bus_ensure_running()
21255d
and shouldn't. bus_ensure_running() should never do callouts. This change
21255d
should fix this however: once we notice that the connection is going down we
21255d
will now fail instantly with ENOTOCONN instead of calling any callbacks.
21255d
21255d
(cherry picked from commit 93a59b1ae5d3bcb0ec1488ebc13d0d1ff4d1729a)
21255d
21255d
Resolves: #1885553
21255d
---
21255d
 src/libsystemd/sd-bus/sd-bus.c | 5 +++--
21255d
 1 file changed, 3 insertions(+), 2 deletions(-)
21255d
21255d
diff --git a/src/libsystemd/sd-bus/sd-bus.c b/src/libsystemd/sd-bus/sd-bus.c
21255d
index a3509f7e89..c65e24b2d1 100644
21255d
--- a/src/libsystemd/sd-bus/sd-bus.c
21255d
+++ b/src/libsystemd/sd-bus/sd-bus.c
21255d
@@ -2059,12 +2059,13 @@ int bus_ensure_running(sd_bus *bus) {
21255d
 
21255d
         assert(bus);
21255d
 
21255d
-        if (IN_SET(bus->state, BUS_UNSET, BUS_CLOSED, BUS_CLOSING))
21255d
-                return -ENOTCONN;
21255d
         if (bus->state == BUS_RUNNING)
21255d
                 return 1;
21255d
 
21255d
         for (;;) {
21255d
+                if (IN_SET(bus->state, BUS_UNSET, BUS_CLOSED, BUS_CLOSING))
21255d
+                        return -ENOTCONN;
21255d
+
21255d
                 r = sd_bus_process(bus, NULL);
21255d
                 if (r < 0)
21255d
                         return r;