From: Zijun Hu <zijun.hu@oss.qualcomm.com>
To: Marcel Holtmann <marcel@holtmann.org>,
Luiz Augusto von Dentz <luiz.dentz@gmail.com>
Cc: Zijun Hu <zijun_hu@icloud.com>,
linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org,
Zijun Hu <zijun.hu@oss.qualcomm.com>
Subject: [PATCH bluez 1/2] obexd/bluetooth: Register profiles added after org.bluez appeared
Date: Tue, 27 Oct 2026 23:45:50 -0700 [thread overview]
Message-ID: <20261027-fix_obex-v1-1-3d91aed181b6@oss.qualcomm.com> (raw)
In-Reply-To: <20261027-fix_obex-v1-0-3d91aed181b6@oss.qualcomm.com>
Issue:
After boot on Debian, bluetoothd and obexd are both running but none of
the obexd server profiles (OPP, FTP, PBAP, ...) is registered.
Why:
A race between name_acquired() and bluetooth_start(). The profiles are
only registered if org.bluez appears after bluetooth_start() has added
them:
plugin_init()
1. bluetooth_init() start watching org.bluez
2. pbap_init(), irmc_init()
e_source_registry_new_sync()
sync call, fails on Debian
3. name_acquired() fired, but the profiles list is
empty, so nothing is registered
obex_server_init()
4. bluetooth_start() adds the profiles to the list,
but nothing registers them
Fix:
Register profiles in bluetooth_start() that name_acquired() did not
register, if org.bluez is already available.
Fixes: 23b28ab759ee ("obexd: Port bluetooth plugin to use external profile support")
Assisted-by: Claude:claude-sonnet-5-5
---
obexd/plugins/bluetooth.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/obexd/plugins/bluetooth.c b/obexd/plugins/bluetooth.c
index 3af1b504d591..b70090971119 100644
--- a/obexd/plugins/bluetooth.c
+++ b/obexd/plugins/bluetooth.c
@@ -45,16 +45,17 @@ struct bluetooth_profile {
const struct obex_service_driver *driver;
char *uuid;
char *path;
};
static GSList *profiles = NULL;
static DBusConnection *connection = NULL;
+static gboolean bluez_available = FALSE;
static DBusMessage *profile_release(DBusConnection *conn, DBusMessage *msg,
void *data)
{
return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
}
static void connect_event(GIOChannel *io, GError *err, void *user_data)
@@ -315,16 +316,18 @@ static const char *service2uuid(uint16_t service)
}
static void name_acquired(DBusConnection *conn, void *user_data)
{
GSList *l;
DBG("org.bluez appeared");
+ bluez_available = TRUE;
+
for (l = profiles; l; l = l->next) {
struct bluetooth_profile *profile = l->data;
if (profile->path != NULL)
continue;
if (register_profile(profile) < 0) {
error("bluetooth: Failed to register profile %s",
@@ -336,16 +339,18 @@ static void name_acquired(DBusConnection *conn, void *user_data)
}
static void name_released(DBusConnection *conn, void *user_data)
{
GSList *l;
DBG("org.bluez disappeared");
+ bluez_available = FALSE;
+
for (l = profiles; l; l = l->next) {
struct bluetooth_profile *profile = l->data;
if (profile->path == NULL)
continue;
unregister_profile(profile);
}
@@ -365,16 +370,25 @@ static void *bluetooth_start(struct obex_server *server, int *err)
continue;
profile = g_new0(struct bluetooth_profile, 1);
profile->driver = driver;
profile->server = server;
profile->uuid = g_strdup(uuid);
profiles = g_slist_prepend(profiles, profile);
+
+ /*
+ * This profile had not been added to the profiles list when
+ * name_acquired() ran, so it was not registered by that call.
+ * Register it here.
+ */
+ if (bluez_available && register_profile(profile) < 0)
+ error("bluetooth: Failed to register profile UUID %s",
+ profile->uuid);
}
return profiles;
}
static void bluetooth_stop(void *data)
{
g_slist_free_full(profiles, profile_free);
@@ -441,16 +455,17 @@ static int bluetooth_init_cb(gboolean at_register)
}
static void bluetooth_exit_cb(gboolean at_unregister)
{
GSList *l;
(void)at_unregister;
g_dbus_remove_watch(connection, listener_id);
+ bluez_available = FALSE;
for (l = profiles; l; l = l->next) {
struct bluetooth_profile *profile = l->data;
if (profile->path == NULL)
continue;
unregister_profile(profile);
--
2.34.1
next prev parent reply other threads:[~2026-10-28 6:46 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-28 6:45 [PATCH bluez 0/2] obexd/bluetooth: Fix profile registration race and clean up Zijun Hu
2026-10-28 6:45 ` Zijun Hu [this message]
2026-10-28 7:48 ` [PATCH bluez 1/2] obexd/bluetooth: Register profiles added after org.bluez appeared Zijun Hu
2026-10-28 6:45 ` [PATCH bluez 2/2] obexd/bluetooth: Clean up redundant code Zijun Hu
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=20261027-fix_obex-v1-1-3d91aed181b6@oss.qualcomm.com \
--to=zijun.hu@oss.qualcomm.com \
--cc=linux-bluetooth@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luiz.dentz@gmail.com \
--cc=marcel@holtmann.org \
--cc=zijun_hu@icloud.com \
/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
all inboxes | Powered by JetHome®