X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Flibsystemd-bus%2Fbus-match.c;h=501a38df70b8aad2905d687fffc5bf070e348624;hb=7027ff61a34a12487712b382a061c654acc3a679;hp=ff1edfaaedc620bf470c657a98aac1b4b6eaf343;hpb=392d5b378ceae5e1fd7c91ca545fcf4cd105744a;p=elogind.git diff --git a/src/libsystemd-bus/bus-match.c b/src/libsystemd-bus/bus-match.c index ff1edfaae..501a38df7 100644 --- a/src/libsystemd-bus/bus-match.c +++ b/src/libsystemd-bus/bus-match.c @@ -146,7 +146,7 @@ static bool value_node_test( case BUS_MATCH_MEMBER: case BUS_MATCH_PATH: case BUS_MATCH_ARG ... BUS_MATCH_ARG_LAST: - return streq(node->value.str, value_str); + return streq_ptr(node->value.str, value_str); case BUS_MATCH_ARG_NAMESPACE ... BUS_MATCH_ARG_NAMESPACE_LAST: return namespace_simple_pattern(node->value.str, value_str); @@ -212,6 +212,9 @@ int bus_match_run( if (!node) return 0; + if (bus && bus->match_callbacks_modified) + return 0; + /* Not these special semantics: when traversing the tree we * usually let bus_match_run() when called for a node * recursively invoke bus_match_run(). There's are two @@ -241,6 +244,17 @@ int bus_match_run( case BUS_MATCH_LEAF: + if (bus) { + if (node->leaf.last_iteration == bus->iteration_counter) + return 0; + + node->leaf.last_iteration = bus->iteration_counter; + } + + r = sd_bus_message_rewind(m, true); + if (r < 0) + return r; + /* Run the callback. And then invoke siblings. */ assert(node->leaf.callback); r = node->leaf.callback(bus, ret, m, node->leaf.userdata); @@ -323,6 +337,9 @@ int bus_match_run( } } + if (bus && bus->match_callbacks_modified) + return 0; + /* And now, let's invoke our siblings */ return bus_match_run(bus, node->next, ret, m); } @@ -481,7 +498,7 @@ static int bus_match_find_compare_value( static int bus_match_add_leaf( struct bus_match_node *where, - sd_message_handler_t callback, + sd_bus_message_handler_t callback, void *userdata, struct bus_match_node **ret) { @@ -511,7 +528,7 @@ static int bus_match_add_leaf( static int bus_match_find_leaf( struct bus_match_node *where, - sd_message_handler_t callback, + sd_bus_message_handler_t callback, void *userdata, struct bus_match_node **ret) { @@ -712,7 +729,7 @@ static int parse_match( } } - if (!greedy_realloc((void**) &value, &value_allocated, j + 2)) { + if (!GREEDY_REALLOC(value, value_allocated, j + 2)) { r = -ENOMEM; goto fail; } @@ -731,8 +748,7 @@ static int parse_match( } else u = 0; - if (!greedy_realloc((void**) &components, &components_allocated, - (n_components + 1) * sizeof(struct match_component))) { + if (!GREEDY_REALLOC(components, components_allocated, n_components + 1)) { r = -ENOMEM; goto fail; } @@ -778,7 +794,7 @@ fail: int bus_match_add( struct bus_match_node *root, const char *match, - sd_message_handler_t callback, + sd_bus_message_handler_t callback, void *userdata, struct bus_match_node **ret) { @@ -819,7 +835,7 @@ finish: int bus_match_remove( struct bus_match_node *root, const char *match, - sd_message_handler_t callback, + sd_bus_message_handler_t callback, void *userdata) { struct match_component *components = NULL;