linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH BlueZ 1/2] core: Fixes order InterfaceAdded
Date: Fri,  9 Feb 2018 12:53:13 +0200	[thread overview]
Message-ID: <20180209105315.24862-1-luiz.dentz@gmail.com> (raw)

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

Registering on the callback of MGMT_OP_READ_ADV_FEATURES causes
InterfacesAdded to be reschedule after the device objects which causes
tools such as PulseAudio to consider it invalid.

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1534857
---
 src/advertising.c | 28 +++++++++++++++-------------
 1 file changed, 15 insertions(+), 13 deletions(-)

diff --git a/src/advertising.c b/src/advertising.c
index 94a8c4050..970c3d87b 100644
--- a/src/advertising.c
+++ b/src/advertising.c
@@ -1032,14 +1032,6 @@ static void read_adv_features_callback(uint8_t status, uint16_t length,
 	if (manager->max_ads == 0)
 		return;
 
-	if (!g_dbus_register_interface(btd_get_dbus_connection(),
-					adapter_get_path(manager->adapter),
-					LE_ADVERTISING_MGR_IFACE, methods,
-					NULL, properties, manager, NULL)) {
-		error("Failed to register " LE_ADVERTISING_MGR_IFACE);
-		return;
-	}
-
 	/* Reset existing instances */
 	if (feat->num_instances)
 		remove_advertising(manager, 0);
@@ -1061,19 +1053,29 @@ static struct btd_adv_manager *manager_create(struct btd_adapter *adapter)
 	}
 
 	manager->mgmt_index = btd_adapter_get_index(adapter);
+	manager->clients = queue_new();
+	manager->supported_flags = MGMT_ADV_FLAG_LOCAL_NAME;
+
+	if (!g_dbus_register_interface(btd_get_dbus_connection(),
+					adapter_get_path(manager->adapter),
+					LE_ADVERTISING_MGR_IFACE, methods,
+					NULL, properties, manager, NULL)) {
+		error("Failed to register " LE_ADVERTISING_MGR_IFACE);
+		goto fail;
+	}
 
 	if (!mgmt_send(manager->mgmt, MGMT_OP_READ_ADV_FEATURES,
 				manager->mgmt_index, 0, NULL,
 				read_adv_features_callback, manager, NULL)) {
 		error("Failed to read advertising features");
-		manager_destroy(manager);
-		return NULL;
+		goto fail;
 	}
 
-	manager->clients = queue_new();
-	manager->supported_flags = MGMT_ADV_FLAG_LOCAL_NAME;
-
 	return manager;
+
+fail:
+	manager_destroy(manager);
+	return NULL;
 }
 
 struct btd_adv_manager *btd_adv_manager_new(struct btd_adapter *adapter)
-- 
2.14.3


             reply	other threads:[~2018-02-09 10:53 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-09 10:53 Luiz Augusto von Dentz [this message]
2018-02-09 10:53 ` [PATCH BlueZ] shared/gatt-client: Reset callbacks when unregistering Luiz Augusto von Dentz
2018-02-09 10:53 ` [PATCH BlueZ 2/2] " Luiz Augusto von Dentz
2018-02-12 11:28   ` Luiz Augusto von Dentz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180209105315.24862-1-luiz.dentz@gmail.com \
    --to=luiz.dentz@gmail.com \
    --cc=linux-bluetooth@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).