Skip to contentSkip to conversation

dbus: Flush pending object manager signals in send_message

PATCH In review Andrew Zaborowski 2 participants 3 messages Mar 23, 2017 – Mar 27, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 dbus: Flush pending object manager signals in send_message

Make sure the PropertiesChanged and InterfacesAdded/Removed signals related to one object path are sent to the dbus socket in the order that they are generated in.

---
 ell/dbus-private.h |  2 ++
 ell/dbus-service.c | 85 +++++++++++++++++++++++++++++++++++++++---------------
 ell/dbus.c         |  5 ++++
 3 files changed, 68 insertions(+), 24 deletions(-)
ell/dbus-private.h +2 -0
index 441e668..9ffedb2 100644
@@ -229,6 +229,8 @@ bool _dbus_object_tree_property_changed(struct l_dbus *dbus,
 					const char *interface_name,
 					const char *property_name);
 
+void _dbus_object_tree_signals_flush(struct l_dbus *dbus, const char *path);
+
 typedef void (*_dbus_name_owner_change_func_t)(const char *name,
 						uint64_t old_owner,
 						uint64_t new_owner,
ell/dbus-service.c +61 -24

130 lines not on this page · raw message

ell/dbus.c +5 -0
index db69c0d..59795a7 100644
@@ -306,6 +306,7 @@ static uint32_t send_message(struct l_dbus *dbus, bool priority,
 {
 	struct message_callback *callback;
 	enum dbus_message_type type;
+	const char *path;
 
 	type = _dbus_message_get_type(message);
 
@@ -338,6 +339,10 @@ static uint32_t send_message(struct l_dbus *dbus, bool priority,
 		return callback->serial;
 	}
 
+	path = l_dbus_message_get_path(message);
+	if (path)
+		_dbus_object_tree_signals_flush(dbus, path);
+
 	l_queue_push_tail(dbus->message_queue, callback);
 
 	if (dbus->is_ready)
Signature · 1 line
2.9.3
#1 lore raw

Hi Andrew,

Quoted 9 lines · Andrew Zaborowski

Make sure the PropertiesChanged and InterfacesAdded/Removed signals related to one object path are sent to the dbus socket in the order that they are generated in.

---
 ell/dbus-private.h |  2 ++
 ell/dbus-service.c | 85 +++++++++++++++++++++++++++++++++++++++---------------
 ell/dbus.c         |  5 ++++
 3 files changed, 68 insertions(+), 24 deletions(-)

<snip>

ell/dbus-service.c static void emit_signals(struct l_idle *idle, void *user_data) · line 1073

Quoted 10 lines
ell/dbus-service.c +4 -2
 	for (entry = l_queue_get_entries(tree->object_managers); entry;
 			entry = entry->next) {
 		manager = entry->data;
 
-		while ((interfaces_removed_rec =
-				l_queue_pop_head(manager->announce_removed))) {
+		while ((interfaces_removed_rec = l_queue_remove_if(
+						manager->announce_removed,
+						match_interfaces_removed_object,
+						node))) {

So we're going from O(n) loop here to something like O(n^2) loop. Can this be made a bit smarter? Same goes for the other loop changes below.
Otherwise I'm fine with the general approach.

Regards,
-Denis

#2 lore raw

Hi Denis,

Quoted 5 lines · Denis Kenzior
Quoted 4 lines · Andrew Zaborowski
        for (entry = l_queue_get_entries(tree->object_managers); entry;
                        entry = entry->next) {
                manager = entry->data;
Quoted 13 lines
Quoted 8 lines
(quoted diff) +0 -2
-               while ((interfaces_removed_rec =
-

l_queue_pop_head(manager->announce_removed))) {

ell/dbus-service.c +3 -0
+               while ((interfaces_removed_rec = l_queue_remove_if(
+                                               manager->announce_removed,
+

match_interfaces_removed_object,
+ node))) {

So we're going from O(n) loop here to something like O(n^2) loop. Can this be made a bit smarter? Same goes for the other loop changes below. Otherwise I'm fine with the general approach.

Ok, I pondered using l_queue_foreach_remove but had opted for a smaller patch.

Best regards