mirror of
https://github.com/systemd/systemd-stable.git
synced 2025-02-09 09:57:26 +03:00
core: make sure to destroy all name watching bus slots when we are kicked off the bus (#5294)
Fixes: #4528
This commit is contained in:
parent
d26fdaa236
commit
8367fea557
@ -1041,6 +1041,7 @@ int bus_init(Manager *m, bool try_bus_connect) {
|
||||
|
||||
static void destroy_bus(Manager *m, sd_bus **bus) {
|
||||
Iterator i;
|
||||
Unit *u;
|
||||
Job *j;
|
||||
|
||||
assert(m);
|
||||
@ -1049,6 +1050,17 @@ static void destroy_bus(Manager *m, sd_bus **bus) {
|
||||
if (!*bus)
|
||||
return;
|
||||
|
||||
/* Make sure all bus slots watching names are released. */
|
||||
HASHMAP_FOREACH(u, m->watch_bus, i) {
|
||||
if (!u->match_bus_slot)
|
||||
continue;
|
||||
|
||||
if (sd_bus_slot_get_bus(u->match_bus_slot) != *bus)
|
||||
continue;
|
||||
|
||||
u->match_bus_slot = sd_bus_slot_unref(u->match_bus_slot);
|
||||
}
|
||||
|
||||
/* Get rid of tracked clients on this bus */
|
||||
if (m->subscribed && sd_bus_track_get_bus(m->subscribed) == *bus)
|
||||
m->subscribed = sd_bus_track_unref(m->subscribed);
|
||||
|
@ -2650,7 +2650,7 @@ void unit_unwatch_bus_name(Unit *u, const char *name) {
|
||||
assert(u);
|
||||
assert(name);
|
||||
|
||||
hashmap_remove_value(u->manager->watch_bus, name, u);
|
||||
(void) hashmap_remove_value(u->manager->watch_bus, name, u);
|
||||
u->match_bus_slot = sd_bus_slot_unref(u->match_bus_slot);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user