summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/libsystemd/sd-bus/bus-control.c6
-rw-r--r--src/libsystemd/sd-bus/bus-internal.h3
-rw-r--r--src/libsystemd/sd-bus/bus-slot.c2
-rw-r--r--src/libsystemd/sd-bus/sd-bus.c3
4 files changed, 10 insertions, 4 deletions
diff --git a/src/libsystemd/sd-bus/bus-control.c b/src/libsystemd/sd-bus/bus-control.c
index b77d6b6ab8..ae1dbf5dcc 100644
--- a/src/libsystemd/sd-bus/bus-control.c
+++ b/src/libsystemd/sd-bus/bus-control.c
@@ -1602,7 +1602,8 @@ int bus_add_match_internal(
sd_bus *bus,
const char *match,
struct bus_match_component *components,
- unsigned n_components) {
+ unsigned n_components,
+ uint64_t cookie) {
assert(bus);
@@ -1663,7 +1664,8 @@ static int bus_remove_match_internal_dbus1(
int bus_remove_match_internal(
sd_bus *bus,
- const char *match) {
+ const char *match,
+ uint64_t cookie) {
assert(bus);
diff --git a/src/libsystemd/sd-bus/bus-internal.h b/src/libsystemd/sd-bus/bus-internal.h
index 6aac969246..5728b02900 100644
--- a/src/libsystemd/sd-bus/bus-internal.h
+++ b/src/libsystemd/sd-bus/bus-internal.h
@@ -54,6 +54,7 @@ struct filter_callback {
struct match_callback {
sd_bus_message_handler_t callback;
+ uint64_t cookie;
unsigned last_iteration;
char *match_string;
@@ -293,6 +294,8 @@ struct sd_bus {
uint64_t hello_flags;
uint64_t attach_flags;
+ uint64_t match_cookie;
+
sd_event_source *input_io_event_source;
sd_event_source *output_io_event_source;
sd_event_source *time_event_source;
diff --git a/src/libsystemd/sd-bus/bus-slot.c b/src/libsystemd/sd-bus/bus-slot.c
index 725265b331..33590c31ac 100644
--- a/src/libsystemd/sd-bus/bus-slot.c
+++ b/src/libsystemd/sd-bus/bus-slot.c
@@ -93,7 +93,7 @@ void bus_slot_disconnect(sd_bus_slot *slot) {
case BUS_MATCH_CALLBACK:
if (slot->match_added)
- bus_remove_match_internal(slot->bus, slot->match_callback.match_string);
+ bus_remove_match_internal(slot->bus, slot->match_callback.match_string, slot->match_callback.cookie);
slot->bus->match_callbacks_modified = true;
bus_match_remove(&slot->bus->match_callbacks, &slot->match_callback);
diff --git a/src/libsystemd/sd-bus/sd-bus.c b/src/libsystemd/sd-bus/sd-bus.c
index 55bcf56ed6..718329337d 100644
--- a/src/libsystemd/sd-bus/sd-bus.c
+++ b/src/libsystemd/sd-bus/sd-bus.c
@@ -3043,6 +3043,7 @@ _public_ int sd_bus_add_match(
}
s->match_callback.callback = callback;
+ s->match_callback.cookie = ++bus->match_cookie;
if (bus->bus_client) {
enum bus_match_scope scope;
@@ -3066,7 +3067,7 @@ _public_ int sd_bus_add_match(
}
}
- r = bus_add_match_internal(bus, s->match_callback.match_string, components, n_components);
+ r = bus_add_match_internal(bus, s->match_callback.match_string, components, n_components, s->match_callback.cookie);
if (r < 0)
goto finish;