mirror of
https://github.com/systemd/systemd-stable.git
synced 2024-12-22 13:33:56 +03:00
bus: break reference cycle between bus and messages
Previously (6ee4f99
bus: break reference cycle between bus and
messages) I committed the test code, but not the actual fix :)
This commit is contained in:
parent
8114dedc59
commit
b7fc42e03a
10
Makefile.am
10
Makefile.am
@ -2096,6 +2096,7 @@ tests += \
|
||||
test-bus-marshal \
|
||||
test-bus-signature \
|
||||
test-bus-chat \
|
||||
test-bus-cleanup \
|
||||
test-bus-server \
|
||||
test-bus-match \
|
||||
test-bus-kernel \
|
||||
@ -2157,6 +2158,15 @@ test_bus_chat_LDADD = \
|
||||
libsystemd-daemon-internal.la \
|
||||
libsystemd-shared.la
|
||||
|
||||
test_bus_cleanup_SOURCES = \
|
||||
src/libsystemd/test-bus-cleanup.c
|
||||
|
||||
test_bus_cleanup_LDADD = \
|
||||
libsystemd-internal.la \
|
||||
libsystemd-id128-internal.la \
|
||||
libsystemd-daemon-internal.la \
|
||||
libsystemd-shared.la
|
||||
|
||||
test_bus_server_SOURCES = \
|
||||
src/libsystemd/test-bus-server.c
|
||||
|
||||
|
@ -1259,12 +1259,25 @@ _public_ sd_bus *sd_bus_ref(sd_bus *bus) {
|
||||
}
|
||||
|
||||
_public_ sd_bus *sd_bus_unref(sd_bus *bus) {
|
||||
unsigned i;
|
||||
|
||||
if (!bus)
|
||||
return NULL;
|
||||
|
||||
if (REFCNT_DEC(bus->n_ref) <= 0)
|
||||
bus_free(bus);
|
||||
i = REFCNT_DEC(bus->n_ref);
|
||||
if (i != bus->rqueue_size + bus->wqueue_size)
|
||||
return NULL;
|
||||
|
||||
for (i = 0; i < bus->rqueue_size; i++)
|
||||
if (bus->rqueue[i]->n_ref > 1)
|
||||
return NULL;
|
||||
|
||||
for (i = 0; i < bus->wqueue_size; i++)
|
||||
if (bus->wqueue[i]->n_ref > 1)
|
||||
return NULL;
|
||||
|
||||
/* we are the only holders on the messages */
|
||||
bus_free(bus);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user