Skip to contentSkip to conversation

Fix message order

PATCH In review Luiz Augusto von Dentz 1 participant 12 messages Sep 3, 2013 – Sep 9, 2013

Subsystems (2)
lore
Share & tools
lore

Luiz Augusto von Dentz

author maintainer
#0 lore raw

v3 cover Fix message order

From: Luiz Augusto von Dentz <[email protected]>

s set fixes a couple of issues introduced with the use of ObjectManager due the processing of signals on idle to group changes, this has been causing issues with external components such as ofono and pulseaudio that sometimes receives connections from devices objects that have pending signals thus cannot be properly processed or have to be assumed paired and with certain UUIDs which is not ideal.

v2: Fixes some commit messages as suggested by Lucas Demarchi, in addition to that rework flush mechanism to honor the order of the pending signals and make it work with any connection.

v3: Add comments regarding the use of dbus_connection_send to prevent recursive calls to g_dbus_flush.

Luiz Augusto von Dentz (10):
build: Fix not rebuilding bluetoothd if gdbus changes
unit: Add gdbus/client_check_order
gdbus: Fix sending ObjectManager/Properties signals out of order
gdbus: Add g_dbus_send_message_with_reply
gdbus: Avoid calling dbus_connection_send*
gdbus: Fix emitting PropertiesChanged twice
core: Make use of g_dbus_send_message_with_reply
neard: Make use of g_dbus_send_message_with_reply audio/media: Make use of g_dbus_send_message_with_reply
obexd: Make use of g_dbus_send_message*

 Makefile.am                   |   2 +-
 gdbus/client.c                |  14 ++--
 gdbus/gdbus.h                 |   3 +
 gdbus/object.c                | 176 ++++++++++++++++++++++++------------------
 obexd/plugins/bluetooth.c     |   2 +-
 obexd/plugins/pcsuite.c       |   5 +-
 obexd/plugins/syncevolution.c |   6 +-
 obexd/src/manager.c           |   3 +-
 plugins/neard.c               |   2 +-
 profiles/audio/media.c        |   2 +-
 src/agent.c                   |  12 +--
 src/profile.c                 |   4 +-
 unit/test-gdbus-client.c      |  71 +++++++++++++++++
 13 files changed, 200 insertions(+), 102 deletions(-)
Signature · 1 line
1.8.3.1
author maintainer
#1 lore raw

PATCH v3 1/10 build: Fix not rebuilding bluetoothd if gdbus changes

From: Luiz Augusto von Dentz <[email protected]>

src_bluetoothd_DEPENDENCIES should list all local libraries including gdbus otherwise it does not get relinked whenever gdbus changes.

---
 Makefile.am | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Makefile.am +1 -1
index 61daec4..4e4b1c5 100644
@@ -157,7 +157,7 @@ src_bluetoothd_LDFLAGS = $(AM_LDFLAGS) -Wl,--export-dynamic \
 				-Wl,--version-script=$(srcdir)/src/bluetooth.ver
 
 src_bluetoothd_DEPENDENCIES = lib/libbluetooth-internal.la \
-						src/bluetooth.service
+				gdbus/libgdbus-internal.la src/bluetooth.service
 
 src_bluetoothd_CFLAGS = $(AM_CFLAGS) -DBLUETOOTH_PLUGIN_BUILTIN \
 					-DPLUGINDIR=\""$(build_plugindir)"\"
Signature · 1 line
1.8.3.1
author maintainer
#2 lore raw

PATCH v3 2/10 unit: Add gdbus/client_check_order

In reply to Luiz Augusto von Dentz

From: Luiz Augusto von Dentz <[email protected]>

---
 unit/test-gdbus-client.c | 71 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 71 insertions(+)
unit/test-gdbus-client.c +71 -0
index a594384..488d4ec 100644
@@ -35,6 +35,7 @@ struct context {
 	GMainLoop *main_loop;
 	DBusConnection *dbus_conn;
 	GDBusClient *dbus_client;
+	GDBusProxy *proxy;
 	void *data;
 	guint timeout_source;
 };
@@ -779,6 +780,74 @@ static void client_string_changed(void)
 	destroy_context(context);
 }
 
+static void property_check_order(const DBusError *err, void *user_data)
+{
+	struct context *context = user_data;
+	GDBusProxy *proxy = context->proxy;
+	DBusMessageIter iter;
+	const char *string;
+
+	g_assert(!dbus_error_is_set(err));
+
+	g_assert(g_dbus_proxy_get_property(proxy, "String", &iter));
+
+	dbus_message_iter_get_basic(&iter, &string);
+	g_assert(g_strcmp0(string, "value1") == 0);
+
+	g_dbus_client_unref(context->dbus_client);
+}
+
+static void proxy_check_order(GDBusProxy *proxy, void *user_data)
+{
+	struct context *context = user_data;
+	const char *string;
+
+	if (g_test_verbose())
+		g_print("proxy %s found\n",
+					g_dbus_proxy_get_interface(proxy));
+
+	context->proxy = proxy;
+	string = "value1";
+	g_assert(g_dbus_proxy_set_property_basic(proxy, "String",
+					DBUS_TYPE_STRING, &string,
+					property_check_order, context,
+					NULL));
+}
+
+static void client_check_order(void)
+{
+	struct context *context = create_context();
+	static const GDBusPropertyTable string_properties[] = {
+		{ "String", "s", get_string, set_string, string_exists },
+		{ },
+	};
+
+	if (context == NULL)
+		return;
+
+	context->data = g_strdup("value");
+	g_dbus_register_interface(context->dbus_conn,
+				SERVICE_PATH, SERVICE_NAME,
+				methods, signals, string_properties,
+				context, NULL);
+
+	context->dbus_client = g_dbus_client_new(context->dbus_conn,
+						SERVICE_NAME, SERVICE_PATH);
+
+	g_dbus_client_set_disconnect_watch(context->dbus_client,
+						disconnect_handler, context);
+	g_dbus_client_set_proxy_handlers(context->dbus_client,
+						proxy_check_order, NULL, NULL,
+						context);
+
+	g_main_loop_run(context->main_loop);
+
+	g_dbus_unregister_interface(context->dbus_conn,
+					SERVICE_PATH, SERVICE_NAME);
+
+	destroy_context(context);
+}
+
 int main(int argc, char *argv[])
 {
 	g_test_init(&argc, &argv, NULL);
@@ -809,5 +878,7 @@ int main(int argc, char *argv[])
 	g_test_add_func("/gdbus/client_string_changed",
 						client_string_changed);
 
+	g_test_add_func("/gdbus/client_check_order", client_check_order);
+
 	return g_test_run();
 }
Signature · 1 line
1.8.3.1
author maintainer
#3 lore raw

PATCH v3 3/10 gdbus: Fix sending ObjectManager/Properties signals out of order

In reply to Luiz Augusto von Dentz

From: Luiz Augusto von Dentz <[email protected]>

In some cases the order of the messages is altered when a message is sent without processing the pending signals first, currently this affect client_check_order unit test:

/gdbus/client_check_order: **
ERROR:unit/test-gdbus-client.c:795:property_check_order: assertion failed: (g_strcmp0(string, "value1") == 0)

As can be observed the value of the property is not yet updated because the signal it is still pending, once this fix is applied the test pass:

/gdbus/client_check_order: OK

Note that the flushing only works when g_dbus_send_message is used so places where dbus_connection_send and other variants are called directly may still change the order.

---
 gdbus/object.c | 69 ++++++++++++++++++++++++++++++++++++++++++++--------------
 1 file changed, 53 insertions(+), 16 deletions(-)
gdbus/object.c +53 -16
index 2f8ef45..83fc4e6 100644
@@ -86,6 +86,7 @@ struct property_data {
 
 static int global_flags = 0;
 static struct generic_data *root;
+static GSList *pending = NULL;
 
 static gboolean process_changes(gpointer user_data);
 static void process_properties_from_interface(struct generic_data *data,
@@ -599,7 +600,9 @@ static void emit_interfaces_added(struct generic_data *data)
 
 	dbus_message_iter_close_container(&iter, &array);
 
-	g_dbus_send_message(data->conn, signal);
+	/* Use dbus_connection_send to avoid recursive calls to g_dbus_flush */
+	dbus_connection_send(data->conn, signal, NULL);
+	dbus_message_unref(signal);
 }
 
 static struct interface_data *find_interface(GSList *interfaces,
@@ -640,6 +643,16 @@ static gboolean g_dbus_args_have_signature(const GDBusArgInfo *args,
 	return TRUE;
 }
 
+static void add_pending(struct generic_data *data)
+{
+	if (data->process_id > 0)
+		return;
+
+	data->process_id = g_idle_add(process_changes, data);
+
+	pending = g_slist_append(pending, data);
+}
+
 static gboolean remove_interface(struct generic_data *data, const char *name)
 {
 	struct interface_data *iface;
@@ -677,10 +690,7 @@ static gboolean remove_interface(struct generic_data *data, const char *name)
 	data->removed = g_slist_prepend(data->removed, iface->name);
 	g_free(iface);
 
-	if (data->process_id > 0)
-		return TRUE;
-
-	data->process_id = g_idle_add(process_changes, data);
+	add_pending(data);
 
 	return TRUE;
 }
@@ -976,14 +986,26 @@ static void emit_interfaces_removed(struct generic_data *data)
 
 	dbus_message_iter_close_container(&iter, &array);
 
-	g_dbus_send_message(data->conn, signal);
+	/* Use dbus_connection_send to avoid recursive calls to g_dbus_flush */
+	dbus_connection_send(data->conn, signal, NULL);
+	dbus_message_unref(signal);
+}
+
+static void remove_pending(struct generic_data *data)
+{
+	if (data->process_id > 0) {
+		g_source_remove(data->process_id);
+		data->process_id = 0;
+	}
+
+	pending = g_slist_remove(pending, data);
 }
 
 static gboolean process_changes(gpointer user_data)
 {
 	struct generic_data *data = user_data;
 
-	data->process_id = 0;
+	remove_pending(data);
 
 	if (data->added != NULL)
 		emit_interfaces_added(data);
@@ -1211,10 +1233,8 @@ done:
 		return TRUE;
 
 	data->added = g_slist_append(data->added, iface);
-	if (data->process_id > 0)
-		return TRUE;
 
-	data->process_id = g_idle_add(process_changes, data);
+	add_pending(data);
 
 	return TRUE;
 }
@@ -1494,6 +1514,21 @@ DBusMessage *g_dbus_create_reply(DBusMessage *message, int type, ...)
 	return reply;
 }
 
+static void g_dbus_flush(DBusConnection *connection)
+{
+	GSList *l;
+
+	for (l = pending; l;) {
+		struct generic_data *data = l->data;
+
+		l = l->next;
+		if (data->conn != connection)
+			continue;
+
+		process_changes(data);
+	}
+}
+
 gboolean g_dbus_send_message(DBusConnection *connection, DBusMessage *message)
 {
 	dbus_bool_t result = FALSE;
@@ -1510,6 +1545,9 @@ gboolean g_dbus_send_message(DBusConnection *connection, DBusMessage *message)
 			goto out;
 	}
 
+	/* Flush pending signal to guarantee message order */
+	g_dbus_flush(connection);
+
 	result = dbus_connection_send(connection, message, NULL);
 
 out:
@@ -1664,10 +1702,12 @@ static void process_properties_from_interface(struct generic_data *data,
 	g_slist_free(invalidated);
 	dbus_message_iter_close_container(&iter, &array);
 
-	g_dbus_send_message(data->conn, signal);
-
 	g_slist_free(iface->pending_prop);
 	iface->pending_prop = NULL;
+
+	/* Use dbus_connection_send to avoid recursive calls to g_dbus_flush */
+	dbus_connection_send(data->conn, signal, NULL);
+	dbus_message_unref(signal);
 }
 
 static void process_property_changes(struct generic_data *data)
@@ -1723,10 +1763,7 @@ void g_dbus_emit_property_changed(DBusConnection *connection,
 	iface->pending_prop = g_slist_prepend(iface->pending_prop,
 						(void *) property);
 
-	if (!data->process_id) {
-		data->process_id = g_idle_add(process_changes, data);
-		return;
-	}
+	add_pending(data);
 }
 
 gboolean g_dbus_get_properties(DBusConnection *connection, const char *path,
Signature · 1 line
1.8.3.1
author maintainer
#4 lore raw

PATCH v3 4/10 gdbus: Add g_dbus_send_message_with_reply

In reply to Luiz Augusto von Dentz

From: Luiz Augusto von Dentz <[email protected]>

g_dbus_send_message_with_reply flushes pending signals before calling dbus_connection_send_with_reply so it does not alter the message order

---
 gdbus/gdbus.h  |  3 +++
 gdbus/object.c | 11 +++++++++++
 2 files changed, 14 insertions(+)
gdbus/gdbus.h +3 -0
index 8b13393..9542109 100644
@@ -250,6 +250,9 @@ DBusMessage *g_dbus_create_reply_valist(DBusMessage *message,
 						int type, va_list args);
 
 gboolean g_dbus_send_message(DBusConnection *connection, DBusMessage *message);
+gboolean g_dbus_send_message_with_reply(DBusConnection *connection,
+					DBusMessage *message,
+					DBusPendingCall **call, int timeout);
 gboolean g_dbus_send_error(DBusConnection *connection, DBusMessage *message,
 				const char *name, const char *format, ...)
 					 __attribute__((format(printf, 4, 5)));
gdbus/object.c +11 -0
index 83fc4e6..773128c 100644
@@ -1556,6 +1556,17 @@ out:
 	return result;
 }
 
+gboolean g_dbus_send_message_with_reply(DBusConnection *connection,
+					DBusMessage *message,
+					DBusPendingCall **call, int timeout)
+{
+	/* Flush pending signal to guarantee message order */
+	g_dbus_flush(connection);
+
+	return dbus_connection_send_with_reply(connection, message, call,
+								timeout);
+}
+
 gboolean g_dbus_send_error_valist(DBusConnection *connection,
 					DBusMessage *message, const char *name,
 					const char *format, va_list args)
Signature · 1 line
1.8.3.1
author maintainer
#5 lore raw

PATCH v3 5/10 gdbus: Avoid calling dbus_connection_send*

In reply to Luiz Augusto von Dentz

From: Luiz Augusto von Dentz <[email protected]>

dbus_connection_send* should not be called directly except by g_dbus_send_message.

---
 gdbus/client.c | 14 ++++-----
 gdbus/object.c | 92 ++++++++++++++++++++++------------------------------------
 2 files changed, 42 insertions(+), 64 deletions(-)
gdbus/client.c +7 -7
index d80e252..8ebfaad 100644
@@ -100,7 +100,7 @@ static gboolean modify_match(DBusConnection *conn, const char *member,
 	dbus_message_append_args(msg, DBUS_TYPE_STRING, &rule,
 						DBUS_TYPE_INVALID);
 
-	if (dbus_connection_send_with_reply(conn, msg, &call, -1) == FALSE) {
+	if (g_dbus_send_message_with_reply(conn, msg, &call, -1) == FALSE) {
 		dbus_message_unref(msg);
 		return FALSE;
 	}
@@ -319,7 +319,7 @@ static void get_all_properties(GDBusProxy *proxy)
 	dbus_message_append_args(msg, DBUS_TYPE_STRING, &proxy->interface,
 							DBUS_TYPE_INVALID);
 
-	if (dbus_connection_send_with_reply(client->dbus_conn, msg,
+	if (g_dbus_send_message_with_reply(client->dbus_conn, msg,
 							&call, -1) == FALSE) {
 		dbus_message_unref(msg);
 		return;
@@ -575,7 +575,7 @@ gboolean g_dbus_proxy_refresh_property(GDBusProxy *proxy, const char *name)
 							&proxy->interface);
 	dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &name);
 
-	if (dbus_connection_send_with_reply(client->dbus_conn, msg,
+	if (g_dbus_send_message_with_reply(client->dbus_conn, msg,
 							&call, -1) == FALSE) {
 		dbus_message_unref(msg);
 		refresh_property_free(data);
@@ -668,7 +668,7 @@ gboolean g_dbus_proxy_set_property_basic(GDBusProxy *proxy,
 	dbus_message_iter_append_basic(&variant, type, value);
 	dbus_message_iter_close_container(&iter, &variant);
 
-	if (dbus_connection_send_with_reply(client->dbus_conn, msg,
+	if (g_dbus_send_message_with_reply(client->dbus_conn, msg,
 							&call, -1) == FALSE) {
 		dbus_message_unref(msg);
 		g_free(data);
@@ -742,7 +742,7 @@ gboolean g_dbus_proxy_method_call(GDBusProxy *proxy, const char *method,
 		setup(&iter, data->user_data);
 	}
 
-	if (dbus_connection_send_with_reply(client->dbus_conn, msg,
+	if (g_dbus_send_message_with_reply(client->dbus_conn, msg,
 					&call, METHOD_CALL_TIMEOUT) == FALSE) {
 		dbus_message_unref(msg);
 		g_free(data);
@@ -1038,7 +1038,7 @@ static void get_managed_objects(GDBusClient *client)
 
 	dbus_message_append_args(msg, DBUS_TYPE_INVALID);
 
-	if (dbus_connection_send_with_reply(client->dbus_conn, msg,
+	if (g_dbus_send_message_with_reply(client->dbus_conn, msg,
 				&client->get_objects_call, -1) == FALSE) {
 		dbus_message_unref(msg);
 		return;
@@ -1102,7 +1102,7 @@ static void get_name_owner(GDBusClient *client, const char *name)
 	dbus_message_append_args(msg, DBUS_TYPE_STRING, &name,
 						DBUS_TYPE_INVALID);
 
-	if (dbus_connection_send_with_reply(client->dbus_conn, msg,
+	if (g_dbus_send_message_with_reply(client->dbus_conn, msg,
 					&client->pending_call, -1) == FALSE) {
 		dbus_message_unref(msg);
 		return;
gdbus/object.c +35 -57

140 lines not on this page · raw message

Signature · 1 line
1.8.3.1
author maintainer
#6 lore raw

PATCH v3 6/10 gdbus: Fix emitting PropertiesChanged twice

In reply to Luiz Augusto von Dentz

From: Luiz Augusto von Dentz <[email protected]>

This fixes double emission of PropertiesChanged introduced by flushing changes, the flushing can happen during the pending processing so the pending_prop flag needs to be updated in the beginning and the list of properties can be freed before g_dbus_send_message as it is not required anymore.

---
 gdbus/object.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
gdbus/object.c +2 -2
index c4cf724..0822fe8 100644
@@ -1642,6 +1642,8 @@ static void process_properties_from_interface(struct generic_data *data,
 	DBusMessageIter iter, dict, array;
 	GSList *invalidated;
 
+	data->pending_prop = FALSE;
+
 	if (iface->pending_prop == NULL)
 		return;
 
@@ -1708,8 +1710,6 @@ static void process_property_changes(struct generic_data *data)
 
 		process_properties_from_interface(data, iface);
 	}
-
-	data->pending_prop = FALSE;
 }
 
 void g_dbus_emit_property_changed(DBusConnection *connection,
Signature · 1 line
1.8.3.1
author maintainer
#7 lore raw

PATCH v3 7/10 core: Make use of g_dbus_send_message_with_reply

In reply to Luiz Augusto von Dentz

From: Luiz Augusto von Dentz <[email protected]>

This replaces dbus_connection_send_with_reply with g_dbus_send_message_with_reply which does not alter message order.

---
 src/agent.c   | 12 ++++++------
 src/profile.c |  4 ++--
 2 files changed, 8 insertions(+), 8 deletions(-)
src/agent.c +6 -6
index b9e6e8c..7880ba6 100644
@@ -370,7 +370,7 @@ static int agent_call_authorize_service(struct agent_request *req,
 				DBUS_TYPE_STRING, &uuid,
 				DBUS_TYPE_INVALID);
 
-	if (dbus_connection_send_with_reply(btd_get_dbus_connection(),
+	if (g_dbus_send_message_with_reply(btd_get_dbus_connection(),
 						req->msg, &req->call,
 						REQUEST_TIMEOUT) == FALSE) {
 		error("D-Bus send failed");
@@ -480,7 +480,7 @@ static int pincode_request_new(struct agent_request *req, const char *device_pat
 	dbus_message_append_args(req->msg, DBUS_TYPE_OBJECT_PATH, &device_path,
 					DBUS_TYPE_INVALID);
 
-	if (dbus_connection_send_with_reply(btd_get_dbus_connection(), req->msg,
+	if (g_dbus_send_message_with_reply(btd_get_dbus_connection(), req->msg,
 					&req->call, REQUEST_TIMEOUT) == FALSE) {
 		error("D-Bus send failed");
 		return -EIO;
@@ -574,7 +574,7 @@ static int passkey_request_new(struct agent_request *req,
 	dbus_message_append_args(req->msg, DBUS_TYPE_OBJECT_PATH, &device_path,
 					DBUS_TYPE_INVALID);
 
-	if (dbus_connection_send_with_reply(btd_get_dbus_connection(), req->msg,
+	if (g_dbus_send_message_with_reply(btd_get_dbus_connection(), req->msg,
 					&req->call, REQUEST_TIMEOUT) == FALSE) {
 		error("D-Bus send failed");
 		return -EIO;
@@ -632,7 +632,7 @@ static int confirmation_request_new(struct agent_request *req,
 				DBUS_TYPE_UINT32, &passkey,
 				DBUS_TYPE_INVALID);
 
-	if (dbus_connection_send_with_reply(btd_get_dbus_connection(), req->msg,
+	if (g_dbus_send_message_with_reply(btd_get_dbus_connection(), req->msg,
 				&req->call, REQUEST_TIMEOUT) == FALSE) {
 		error("D-Bus send failed");
 		return -EIO;
@@ -689,7 +689,7 @@ static int authorization_request_new(struct agent_request *req,
 				DBUS_TYPE_OBJECT_PATH, &device_path,
 				DBUS_TYPE_INVALID);
 
-	if (dbus_connection_send_with_reply(btd_get_dbus_connection(), req->msg,
+	if (g_dbus_send_message_with_reply(btd_get_dbus_connection(), req->msg,
 				&req->call, REQUEST_TIMEOUT) == FALSE) {
 		error("D-Bus send failed");
 		return -EIO;
@@ -823,7 +823,7 @@ static int display_pincode_request_new(struct agent_request *req,
 					DBUS_TYPE_STRING, &pincode,
 					DBUS_TYPE_INVALID);
 
-	if (dbus_connection_send_with_reply(btd_get_dbus_connection(), req->msg,
+	if (g_dbus_send_message_with_reply(btd_get_dbus_connection(), req->msg,
 				&req->call, REQUEST_TIMEOUT) == FALSE) {
 		error("D-Bus send failed");
 		return -EIO;
src/profile.c +2 -2
index 90c3535..57aead7 100644
@@ -938,7 +938,7 @@ static bool send_new_connection(struct ext_profile *ext, struct ext_io *conn)
 
 	dbus_message_iter_close_container(&iter, &dict);
 
-	if (!dbus_connection_send_with_reply(btd_get_dbus_connection(),
+	if (!g_dbus_send_message_with_reply(btd_get_dbus_connection(),
 						msg, &conn->pending, -1)) {
 		error("%s: sending NewConnection failed", ext->name);
 		dbus_message_unref(msg);
@@ -1682,7 +1682,7 @@ static int send_disconn_req(struct ext_profile *ext, struct ext_io *conn)
 	dbus_message_append_args(msg, DBUS_TYPE_OBJECT_PATH, &path,
 							DBUS_TYPE_INVALID);
 
-	if (!dbus_connection_send_with_reply(btd_get_dbus_connection(),
+	if (!g_dbus_send_message_with_reply(btd_get_dbus_connection(),
 						msg, &conn->pending, -1)) {
 		error("%s: sending RequestDisconnection failed", ext->name);
 		dbus_message_unref(msg);
Signature · 1 line
1.8.3.1
author maintainer
#8 lore raw

PATCH v3 8/10 neard: Make use of g_dbus_send_message_with_reply

In reply to Luiz Augusto von Dentz

From: Luiz Augusto von Dentz <[email protected]>

This replaces dbus_connection_send_with_reply with g_dbus_send_message_with_reply which does not alter message order.

---
 plugins/neard.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
plugins/neard.c +1 -1
index e4a4d71..ea91c4d 100644
@@ -158,7 +158,7 @@ static void register_agent(bool append_carrier)
 		dbus_message_append_args(message, DBUS_TYPE_STRING, &carrier,
 							DBUS_TYPE_INVALID);
 
-	if (!dbus_connection_send_with_reply(btd_get_dbus_connection(),
+	if (!g_dbus_send_message_with_reply(btd_get_dbus_connection(),
 							message, &call, -1)) {
 		dbus_message_unref(message);
 		error("D-Bus send failed");
Signature · 1 line
1.8.3.1
author maintainer
#9 lore raw

PATCH v3 9/10 audio/media: Make use of g_dbus_send_message_with_reply

In reply to Luiz Augusto von Dentz

From: Luiz Augusto von Dentz <[email protected]>

This replaces dbus_connection_send_with_reply with g_dbus_send_message_with_reply which does not alter message order.

---
 profiles/audio/media.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
profiles/audio/media.c +1 -1
index 5a06b99..9c72b8d 100644
@@ -325,7 +325,7 @@ static gboolean media_endpoint_async_call(DBusMessage *msg,
 	request = g_new0(struct endpoint_request, 1);
 
 	/* Timeout should be less than avdtp request timeout (4 seconds) */
-	if (dbus_connection_send_with_reply(btd_get_dbus_connection(),
+	if (g_dbus_send_message_with_reply(btd_get_dbus_connection(),
 						msg, &request->call,
 						REQUEST_TIMEOUT) == FALSE) {
 		error("D-Bus send failed");
Signature · 1 line
1.8.3.1
author maintainer
#10 lore raw

PATCH v3 10/10 obexd: Make use of g_dbus_send_message*

In reply to Luiz Augusto von Dentz

From: Luiz Augusto von Dentz <[email protected]>

This replaces dbus_connection_send* with g_dbus_send_message* which do not alter message order.

---
 obexd/plugins/bluetooth.c     | 2 +-
 obexd/plugins/pcsuite.c       | 5 ++---
 obexd/plugins/syncevolution.c | 6 +++---
 obexd/src/manager.c           | 3 +--
 4 files changed, 7 insertions(+), 9 deletions(-)
obexd/plugins/bluetooth.c +1 -1
index e4d518e..10f5e4f 100644
@@ -317,7 +317,7 @@ static int register_profile(struct bluetooth_profile *profile)
 	}
 	dbus_message_iter_close_container(&iter, &opt);
 
-	if (!dbus_connection_send_with_reply(connection, msg, &call, -1)) {
+	if (!g_dbus_send_message_with_reply(connection, msg, &call, -1)) {
 		ret = -1;
 		unregister_profile(profile);
 		goto failed;
obexd/plugins/pcsuite.c +2 -3
index 4ce2fe4..6460aa9 100644
@@ -351,7 +351,7 @@ static gboolean send_backup_dbus_message(const char *oper,
 					DBUS_TYPE_INVALID);
 
 	if (strcmp(oper, "open") == 0) {
-		ret = dbus_connection_send_with_reply(conn, msg, &pending_call,
+		ret = g_dbus_send_message_with_reply(conn, msg, &pending_call,
 							BACKUP_DBUS_TIMEOUT);
 		dbus_message_unref(msg);
 		if (ret) {
@@ -363,8 +363,7 @@ static gboolean send_backup_dbus_message(const char *oper,
 		} else
 			dbus_connection_unref(conn);
 	} else {
-		ret = dbus_connection_send(conn, msg, NULL);
-		dbus_message_unref(msg);
+		g_dbus_send_message(conn, msg);
 		dbus_connection_unref(conn);
 	}
 
obexd/plugins/syncevolution.c +3 -3
index 2d25d28..edc00c8 100644
@@ -314,7 +314,7 @@ static int synce_close(void *object)
 	dbus_message_append_args(msg, DBUS_TYPE_BOOLEAN, &normal,
 				DBUS_TYPE_STRING, &error, DBUS_TYPE_INVALID);
 
-	dbus_connection_send_with_reply(context->dbus_conn, msg, &call, -1);
+	g_dbus_send_message_with_reply(context->dbus_conn, msg, &call, -1);
 	dbus_pending_call_set_notify(call, close_cb, NULL, NULL);
 	dbus_message_unref(msg);
 	dbus_pending_call_unref(call);
@@ -380,7 +380,7 @@ static ssize_t synce_read(void *object, void *buf, size_t count)
 	dbus_message_append_args(msg, DBUS_TYPE_BOOLEAN, &authenticate,
 			DBUS_TYPE_STRING, &session, DBUS_TYPE_INVALID);
 
-	if (!dbus_connection_send_with_reply(conn, msg, &call, -1)) {
+	if (!g_dbus_send_message_with_reply(conn, msg, &call, -1)) {
 		error("D-Bus call to %s failed.", SYNCE_SERVER_INTERFACE);
 		dbus_message_unref(msg);
 		return -EPERM;
@@ -424,7 +424,7 @@ static ssize_t synce_write(void *object, const void *buf, size_t count)
 	dbus_message_append_args(msg, DBUS_TYPE_STRING, &type,
 						DBUS_TYPE_INVALID);
 
-	if (!dbus_connection_send_with_reply(context->dbus_conn, msg,
+	if (!g_dbus_send_message_with_reply(context->dbus_conn, msg,
 								&call, -1)) {
 		error("D-Bus call to %s failed.", SYNCE_CONN_INTERFACE);
 		dbus_message_unref(msg);
obexd/src/manager.c +1 -2
index dbfbef8..f64b7b9 100644
@@ -776,8 +776,7 @@ int manager_request_authorization(struct obex_transfer *transfer, int32_t time,
 	dbus_message_append_args(msg, DBUS_TYPE_OBJECT_PATH, &transfer->path,
 							DBUS_TYPE_INVALID);
 
-	if (!dbus_connection_send_with_reply(connection,
-					msg, &call, TIMEOUT)) {
+	if (!g_dbus_send_message_with_reply(connection, msg, &call, TIMEOUT)) {
 		dbus_message_unref(msg);
 		return -EPERM;
 	}
Signature · 1 line
1.8.3.1
author maintainer
#11 lore raw
In reply to Luiz Augusto von Dentz

Hi,

Quoted 43 lines · Luiz Augusto von Dentz

From: Luiz Augusto von Dentz <[email protected]>

s set fixes a couple of issues introduced with the use of ObjectManager due the processing of signals on idle to group changes, this has been causing issues with external components such as ofono and pulseaudio that sometimes receives connections from devices objects that have pending signals thus cannot be properly processed or have to be assumed paired and with certain UUIDs which is not ideal.

v2: Fixes some commit messages as suggested by Lucas Demarchi, in addition to that rework flush mechanism to honor the order of the pending signals and make it work with any connection.

v3: Add comments regarding the use of dbus_connection_send to prevent recursive calls to g_dbus_flush.

Luiz Augusto von Dentz (10):
build: Fix not rebuilding bluetoothd if gdbus changes
unit: Add gdbus/client_check_order
gdbus: Fix sending ObjectManager/Properties signals out of order
gdbus: Add g_dbus_send_message_with_reply
gdbus: Avoid calling dbus_connection_send*
gdbus: Fix emitting PropertiesChanged twice
core: Make use of g_dbus_send_message_with_reply
neard: Make use of g_dbus_send_message_with_reply audio/media: Make use of g_dbus_send_message_with_reply
obexd: Make use of g_dbus_send_message*

 Makefile.am                   |   2 +-
 gdbus/client.c                |  14 ++--
 gdbus/gdbus.h                 |   3 +
 gdbus/object.c                | 176 ++++++++++++++++++++++++------------------
 obexd/plugins/bluetooth.c     |   2 +-
 obexd/plugins/pcsuite.c       |   5 +-
 obexd/plugins/syncevolution.c |   6 +-
 obexd/src/manager.c           |   3 +-
 plugins/neard.c               |   2 +-
 profiles/audio/media.c        |   2 +-
 src/agent.c                   |  12 +--
 src/profile.c                 |   4 +-
 unit/test-gdbus-client.c      |  71 +++++++++++++++++
 13 files changed, 200 insertions(+), 102 deletions(-)
Quoted 2 lines

--
1.8.3.1

I went ahead and pushed this upstream.

Signature · 1 line
Luiz Augusto von Dentz