* [PATCH bluez 0/2] obexd/bluetooth: Fix profile registration race and clean up
@ 2026-10-28 6:45 Zijun Hu
2026-10-28 6:45 ` [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
0 siblings, 2 replies; 4+ messages in thread
From: Zijun Hu @ 2026-10-28 6:45 UTC (permalink / raw)
To: Marcel Holtmann, Luiz Augusto von Dentz
Cc: Zijun Hu, linux-bluetooth, linux-kernel, Zijun Hu
This series is to fix below profile registration issue and do clean up:
After boot on Debian, bluetoothd and obexd are both running but none of
the obexd server profiles (OPP, FTP, PBAP, ...) is registered.
obexd registers profiles from name_acquired(), but only adds them to its
list later in bluetooth_start(). If org.bluez appears first, nothing is
registered.
Signed-off-by: Zijun Hu <zijun.hu@oss.qualcomm.com>
---
Zijun Hu (2):
obexd/bluetooth: Register profiles added after org.bluez appeared
obexd/bluetooth: Clean up redundant code
obexd/plugins/bluetooth.c | 28 ++++++++++++++++++++--------
1 file changed, 20 insertions(+), 8 deletions(-)
---
base-commit: b0bf49270d445da0852851f393cd67a0a1e5f05e
change-id: 20261027-fix_obex-c912a68e73a5
Best regards,
--
Zijun Hu <zijun.hu@oss.qualcomm.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH bluez 1/2] obexd/bluetooth: Register profiles added after org.bluez appeared
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
2026-10-28 7:48 ` Zijun Hu
2026-10-28 6:45 ` [PATCH bluez 2/2] obexd/bluetooth: Clean up redundant code Zijun Hu
1 sibling, 1 reply; 4+ messages in thread
From: Zijun Hu @ 2026-10-28 6:45 UTC (permalink / raw)
To: Marcel Holtmann, Luiz Augusto von Dentz
Cc: Zijun Hu, linux-bluetooth, linux-kernel, Zijun Hu
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
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH bluez 2/2] obexd/bluetooth: Clean up redundant code
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 ` [PATCH bluez 1/2] obexd/bluetooth: Register profiles added after org.bluez appeared Zijun Hu
@ 2026-10-28 6:45 ` Zijun Hu
1 sibling, 0 replies; 4+ messages in thread
From: Zijun Hu @ 2026-10-28 6:45 UTC (permalink / raw)
To: Marcel Holtmann, Luiz Augusto von Dentz
Cc: Zijun Hu, linux-bluetooth, linux-kernel, Zijun Hu
register_profile() already frees profile->path and sets it to NULL when
it fails, so the same cleanup in name_acquired() does nothing, and the
error message always prints a NULL path. Drop the cleanup and print the
profile UUID instead.
Also drop the trailing return in void functions.
Assisted-by: Claude:claude-sonnet-5-5
---
obexd/plugins/bluetooth.c | 13 +++++--------
1 file changed, 5 insertions(+), 8 deletions(-)
diff --git a/obexd/plugins/bluetooth.c b/obexd/plugins/bluetooth.c
index b70090971119..0aeb1becdf32 100644
--- a/obexd/plugins/bluetooth.c
+++ b/obexd/plugins/bluetooth.c
@@ -88,17 +88,16 @@ done:
if (obex_server_new_connection(server, io, omtu, imtu, stream) < 0)
g_io_channel_shutdown(io, TRUE, NULL);
return;
drop:
error("%s", err->message);
g_io_channel_shutdown(io, TRUE, NULL);
- return;
}
static DBusMessage *invalid_args(DBusMessage *msg)
{
return g_dbus_create_error(msg, "org.bluez.Error.InvalidArguments",
"Invalid arguments in method call");
}
@@ -324,22 +323,19 @@ static void name_acquired(DBusConnection *conn, void *user_data)
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",
- profile->path);
- g_free(profile->path);
- profile->path = NULL;
- }
+ if (register_profile(profile) < 0)
+ error("bluetooth: Failed to register profile UUID %s",
+ profile->uuid);
}
}
static void name_released(DBusConnection *conn, void *user_data)
{
GSList *l;
DBG("org.bluez disappeared");
@@ -479,14 +475,15 @@ static void bluetooth_exit_cb(gboolean at_unregister)
obex_transport_driver_unregister(&driver);
}
static int bluetooth_init(void)
{
return logind_register(bluetooth_init_cb, bluetooth_exit_cb);
}
+
static void bluetooth_exit(void)
{
- return logind_unregister(bluetooth_init_cb, bluetooth_exit_cb);
+ logind_unregister(bluetooth_init_cb, bluetooth_exit_cb);
}
OBEX_PLUGIN_DEFINE(bluetooth, bluetooth_init, bluetooth_exit)
--
2.34.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH bluez 1/2] obexd/bluetooth: Register profiles added after org.bluez appeared
2026-10-28 6:45 ` [PATCH bluez 1/2] obexd/bluetooth: Register profiles added after org.bluez appeared Zijun Hu
@ 2026-10-28 7:48 ` Zijun Hu
0 siblings, 0 replies; 4+ messages in thread
From: Zijun Hu @ 2026-10-28 7:48 UTC (permalink / raw)
To: Marcel Holtmann, Luiz Augusto von Dentz
Cc: Zijun Hu, linux-bluetooth, linux-kernel
On 10/28/2026 2:45 PM, Zijun Hu wrote:
> 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
Log segment:
Oct 27 08:38:17 debian obexd[1456]: OBEX daemon 5.82
Oct 27 08:38:17 debian obexd[1456]: obexd/src/main.c:main() Entering main loop
Oct 27 08:38:17 debian obexd[1456]: obexd/src/manager.c:manager_init()
Oct 27 08:38:17 debian dbus-daemon[1207]: [session uid=1000 pid=1207 pidfd=5] Successfully activated service 'org.bluez.obex'
Oct 27 08:38:17 debian obexd[1456]: obexd/src/plugin.c:plugin_init() Loading builtin plugins
Oct 27 08:38:17 debian obexd[1456]: obexd/src/mimetype.c:obex_mime_type_driver_register() driver 0xaaaaac0b6508 mimetype x-obex/folder-listing registered
Oct 27 08:38:17 debian obexd[1456]: obexd/src/mimetype.c:obex_mime_type_driver_register() driver 0xaaaaac0b6498 mimetype x-obex/capability registered
Oct 27 08:38:17 debian systemd[1188]: Started obex.service - Bluetooth OBEX service.
Oct 27 08:38:17 debian obexd[1456]: obexd/src/mimetype.c:obex_mime_type_driver_register() driver 0xaaaaac0b6428 mimetype x-obex/folder-listing registered
Oct 27 08:38:17 debian obexd[1456]: obexd/src/mimetype.c:obex_mime_type_driver_register() driver 0xaaaaac0bef18 mimetype (null) registered
Oct 27 08:38:17 debian obexd[1456]: obexd/src/plugin.c:add_plugin() Plugin filesystem loaded
Oct 27 08:38:17 debian obexd[1456]: obexd/src/transport.c:obex_transport_driver_register() driver 0xaaaaac0b6330 transport bluetooth registered
Oct 27 08:38:17 debian obexd[1456]: obexd/src/plugin.c:add_plugin() Plugin bluetooth loaded
Oct 27 08:38:17 debian obexd[1456]: obexd/src/service.c:obex_service_driver_register() driver 0xaaaaac0b62a8 service Nokia OBEX PC Suite Services registered
Oct 27 08:38:17 debian obexd[1456]: obexd/src/mimetype.c:obex_mime_type_driver_register() driver 0xaaaaac0b6238 mimetype application/vnd.nokia-backup registered
Oct 27 08:38:17 debian obexd[1456]: obexd/src/plugin.c:add_plugin() Plugin pcsuite loaded
Oct 27 08:38:17 debian obexd[1456]: obexd/src/service.c:obex_service_driver_register() driver 0xaaaaac0b61b0 service Object Push server registered
Oct 27 08:38:17 debian obexd[1456]: obexd/src/plugin.c:add_plugin() Plugin opp loaded
Oct 27 08:38:17 debian obexd[1456]: obexd/src/service.c:obex_service_driver_register() driver 0xaaaaac0bee90 service File Transfer server registered
Oct 27 08:38:17 debian obexd[1456]: obexd/src/plugin.c:add_plugin() Plugin ftp loaded
Oct 27 08:38:17 debian obexd[1456]: obexd/plugins/irmc.c:irmc_init()
Oct 27 08:38:17 debian dbus-daemon[1207]: [session uid=1000 pid=1207 pidfd=5] Activating via systemd: service name='org.gnome.evolution.dataserver.Sources5'
unit='evolution-source-registry.service' requested by ':1.33' (uid=1000 pid=1456 comm="/usr/libexec/bluetooth/obexd -d")
Oct 27 08:38:17 debian dbus-daemon[1207]: [session uid=1000 pid=1207 pidfd=5] Activation via systemd failed for unit 'evolution-source-registry.service': Unit
evolution-source-registry.service not found.
Oct 27 08:38:17 debian obexd[1456]: obexd/plugins/bluetooth.c:name_acquired() org.bluez appeared
Oct 27 08:38:17 debian obexd[1456]: Unable to acquire registry: Error calling StartServiceByName for org.gnome.evolution.dataserver.Sources5: Unit evolution-source-registry.service not
found.
Oct 27 08:38:17 debian dbus-daemon[1207]: [session uid=1000 pid=1207 pidfd=5] Activating via systemd: service name='org.gnome.evolution.dataserver.Sources5'
unit='evolution-source-registry.service' requested by ':1.33' (uid=1000 pid=1456 comm="/usr/libexec/bluetooth/obexd -d")
Oct 27 08:38:17 debian dbus-daemon[1207]: [session uid=1000 pid=1207 pidfd=5] Activation via systemd failed for unit 'evolution-source-registry.service': Unit
evolution-source-registry.service not found.
Oct 27 08:38:17 debian obexd[1456]: Unable to acquire registry: Error calling StartServiceByName for org.gnome.evolution.dataserver.Sources5: Unit evolution-source-registry.service not
found.
Oct 27 08:38:17 debian obexd[1456]: obexd/src/mimetype.c:obex_mime_type_driver_register() driver 0xaaaaac0b69a0 mimetype (null) registered
Oct 27 08:38:17 debian obexd[1456]: obexd/src/mimetype.c:obex_mime_type_driver_register() driver 0xaaaaac0b6930 mimetype x-bt/message registered
Oct 27 08:38:17 debian obexd[1456]: obexd/src/mimetype.c:obex_mime_type_driver_register() driver 0xaaaaac0b68c0 mimetype x-obex/folder-listing registered
Oct 27 08:38:17 debian obexd[1456]: obexd/src/mimetype.c:obex_mime_type_driver_register() driver 0xaaaaac0b6850 mimetype x-bt/MAP-msg-listing registered
Oct 27 08:38:17 debian obexd[1456]: obexd/src/mimetype.c:obex_mime_type_driver_register() driver 0xaaaaac0b67e0 mimetype x-bt/MAP-NotificationRegistration registered
Oct 27 08:38:17 debian obexd[1456]: obexd/src/mimetype.c:obex_mime_type_driver_register() driver 0xaaaaac0b6770 mimetype x-bt/messageStatus registered
Oct 27 08:38:17 debian obexd[1456]: obexd/src/mimetype.c:obex_mime_type_driver_register() driver 0xaaaaac0b6700 mimetype x-bt/MAP-messageUpdate registered
Oct 27 08:38:17 debian obexd[1456]: obexd/src/mimetype.c:obex_mime_type_driver_register() driver 0xaaaaac0c0090 mimetype x-bt/MASInstanceInformation registered
Oct 27 08:38:17 debian obexd[1456]: obexd/src/mimetype.c:obex_mime_type_driver_register() driver 0xaaaaac0c0020 mimetype x-bt/MAP-notification-filter registered
Oct 27 08:38:17 debian obexd[1456]: obexd/src/service.c:obex_service_driver_register() driver 0xaaaaac0b7540 service Message Access server registered
Oct 27 08:38:17 debian obexd[1456]: obexd/src/plugin.c:add_plugin() Plugin mas loaded
Oct 27 08:38:17 debian obexd[1456]: obexd/src/mimetype.c:obex_mime_type_driver_register() driver 0xaaaaac0b7388 mimetype x-bt/MAP-event-report registered
Oct 27 08:38:17 debian obexd[1456]: obexd/src/service.c:obex_service_driver_register() driver 0xaaaaac0b7300 service Message Notification server registered
Oct 27 08:38:17 debian obexd[1456]: obexd/src/plugin.c:add_plugin() Plugin mns loaded
Oct 27 08:38:17 debian obexd[1456]: obexd/client/bluetooth.c:bluetooth_init()
Oct 27 08:38:17 debian obexd[1456]: obexd/client/transport.c:obc_transport_register() transport 0xaaaaac0c0328 name Bluetooth registered
Oct 27 08:38:17 debian obexd[1456]: obexd/client/manager.c:client_manager_init() Module bluetooth loaded
Oct 27 08:38:17 debian obexd[1456]: obexd/client/opp.c:opp_init()
Oct 27 08:38:17 debian systemd[1]: Started upower.service - Daemon for power management.
Oct 27 08:38:17 debian obexd[1456]: obexd/client/driver.c:obc_driver_register() driver 0xaaaaac0c0210 service OPP registered
Oct 27 08:38:17 debian obexd[1456]: obexd/client/manager.c:client_manager_init() Module opp loaded
Oct 27 08:38:17 debian obexd[1456]: obexd/client/ftp.c:ftp_init()
Oct 27 08:38:17 debian obexd[1456]: obexd/client/driver.c:obc_driver_register() driver 0xaaaaac0c0280 service FTP registered
Oct 27 08:38:17 debian obexd[1456]: obexd/client/driver.c:obc_driver_register() driver 0xaaaaac0c0248 service PCSUITE registered
Oct 27 08:38:17 debian obexd[1456]: obexd/client/manager.c:client_manager_init() Module ftp loaded
Oct 27 08:38:17 debian obexd[1456]: obexd/client/pbap.c:pbap_init()
Oct 27 08:38:17 debian dbus-daemon[897]: [system] Successfully activated service 'org.freedesktop.UPower'
Oct 27 08:38:17 debian obexd[1456]: obexd/client/driver.c:obc_driver_register() driver 0xaaaaac0c02b8 service PBAP registered
Oct 27 08:38:17 debian obexd[1456]: obexd/client/manager.c:client_manager_init() Module pbap loaded
Oct 27 08:38:17 debian obexd[1456]: obexd/client/sync.c:sync_init()
Oct 27 08:38:17 debian obexd[1456]: obexd/client/driver.c:obc_driver_register() driver 0xaaaaac0c02f0 service SYNC registered
Oct 27 08:38:17 debian obexd[1456]: obexd/client/manager.c:client_manager_init() Module sync loaded
Oct 27 08:38:17 debian obexd[1456]: obexd/client/map.c:map_init()
Oct 27 08:38:17 debian obexd[1456]: obexd/client/driver.c:obc_driver_register() driver 0xaaaaac0c01d8 service MAP registered
Oct 27 08:38:17 debian obexd[1456]: obexd/client/manager.c:client_manager_init() Module map loaded
Oct 27 08:38:17 debian obexd[1456]: obexd/client/bip.c:bip_init()
Oct 27 08:38:17 debian obexd[1456]: obexd/client/driver.c:obc_driver_register() driver 0xaaaaac0c0130 service BIP-AVRCP registered
Oct 27 08:38:17 debian obexd[1456]: obexd/client/manager.c:client_manager_init() Module bip loaded
Oct 27 08:38:17 debian obexd[1456]: obexd/client/pbap.c:name_acquired() org.bluez appeared
Oct 27 08:38:17 debian obexd[1456]: obexd/client/pbap.c:register_profile_reply() Profile /org/bluez/obex/0000112e_0000_1000_8000_00805f9b34fb registered
Oct 27 08:38:17 debian obexd[1456]: obexd/src/manager.c:register_agent() Agent registered
Oct 27 08:38:17 debian urm[859]: [RESTUNE_SIGNAL_REGISTRY] [ERROR] getSignalConfigByIdAndType: Signal with: ID [0x00020001] and Type [0x00000000] not found in the registry.
Dropping Request.
Oct 27 08:38:17 debian urm[859]: [RESTUNE_SIGNAL_REGISTRY] [ERROR] getSignalConfigByIdAndType: Signal with: ID [0x00020001] and Type [0x00000000] not found in the registry.
Dropping Request.
Oct 27 08:38:17 debian urm[859]: [RESTUNE_SIGNAL_REGISTRY] [ERROR] getSignalConfigByIdAndType: Signal with: ID [0x00020001] and Type [0x00000000] not found in the registry.
Dropping Request.
Oct 27 08:38:17 debian pkexec[1481]: pam_unix(polkit-1:session): session opened for user root(uid=0) by debian(uid=1000)
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-10-28 7:48 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [PATCH bluez 1/2] obexd/bluetooth: Register profiles added after org.bluez appeared Zijun Hu
2026-10-28 7:48 ` Zijun Hu
2026-10-28 6:45 ` [PATCH bluez 2/2] obexd/bluetooth: Clean up redundant code Zijun Hu
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®