teknoraver / rpms / systemd

Forked from rpms/systemd 2 months ago
Clone

Blame SOURCES/0443-sd-bus-break-the-loop-in-bus_ensure_running-if-the-b.patch

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