From: Andrew Sayers <kernel.org@pileofstuff.org>
To: linux-bluetooth@vger.kernel.org
Cc: luiz.dentz@gmail.com, pav@iki.fi, frederic.danis@collabora.com,
Andrew Sayers <kernel.org@pileofstuff.org>
Subject: [PATCH BlueZ v2 2/3] pbap: use the public DBus connection
Date: Wed, 11 Jun 2025 14:06:14 +0100 [thread overview]
Message-ID: <20250611131125.450039-3-kernel.org@pileofstuff.org> (raw)
In-Reply-To: <20250611131125.450039-1-kernel.org@pileofstuff.org>
PBAP must not use its own private DBus connection, as it needs to
receive messages sent to the bus name of the public connection.
PBAP must not unregister itself when the program is exiting, as it might
cause a long delay. Unregistering at exit is redundant anyway, as the
service will be implicitly unregistered when the connection is closed.
But PBAP must unregister itself when the user becomes inactive mid-session,
so systems with multiple users logged in at once can share bluetooth.
Use the public DBus connection instead of a private one,
and explicitly unregister the profile if appropriate.
Thanks Pauli Virtanen for pointing out the exit issue:
https://lore.kernel.org/linux-bluetooth/ae15a9fa4bf0bd509dd3d44f1f364e241e50956c.camel@iki.fi/
Reported-by: Frédéric Danis <frederic.danis@collabora.com>
Closes: https://lore.kernel.org/linux-bluetooth/333ad76e-0aba-4f93-b141-8e69fb47535f@collabora.com/
Suggested-by: Pauli Virtanen <pav@iki.fi>
Signed-off-by: Andrew Sayers <kernel.org@pileofstuff.org>
---
obexd/client/pbap.c | 24 +++++++++++++++++++++---
1 file changed, 21 insertions(+), 3 deletions(-)
diff --git a/obexd/client/pbap.c b/obexd/client/pbap.c
index 7d651722a..78c46bf86 100644
--- a/obexd/client/pbap.c
+++ b/obexd/client/pbap.c
@@ -1462,7 +1462,7 @@ static int pbap_init_cb(gboolean at_register)
DBG("");
- conn = obex_setup_dbus_connection_private(NULL, NULL);
+ conn = obex_get_dbus_connection();
if (!conn)
return -EIO;
@@ -1485,9 +1485,28 @@ static int pbap_init_cb(gboolean at_register)
static void pbap_exit_cb(gboolean at_unregister)
{
- (void)at_unregister;
+ DBusMessage *msg;
+ DBusMessageIter iter;
+ char *uuid = PBAP_CLIENT_UUID;
+
DBG("");
+ if (!at_unregister) {
+ client_path = g_strconcat("/org/bluez/obex/", uuid, NULL);
+ g_strdelimit(client_path, "-", '_');
+
+ msg = dbus_message_new_method_call("org.bluez", "/org/bluez",
+ "org.bluez.ProfileManager1",
+ "UnregisterProfile");
+
+ dbus_message_iter_init_append(msg, &iter);
+
+ dbus_message_iter_append_basic(&iter, DBUS_TYPE_OBJECT_PATH,
+ &client_path);
+
+ g_dbus_send_message(system_conn, msg);
+ }
+
g_dbus_remove_watch(system_conn, listener_id);
unregister_profile();
@@ -1499,7 +1518,6 @@ static void pbap_exit_cb(gboolean at_unregister)
}
if (conn) {
- dbus_connection_close(conn);
dbus_connection_unref(conn);
conn = NULL;
}
--
2.49.0
next prev parent reply other threads:[~2025-06-11 13:12 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-11 13:06 [PATCH BlueZ v2 0/3] pbap: use the public DBus connection Andrew Sayers
2025-06-11 13:06 ` [PATCH BlueZ v2 1/3] obexd: Pass at_(un)register value to logind callbacks Andrew Sayers
2025-06-11 14:35 ` pbap: use the public DBus connection bluez.test.bot
2025-06-11 13:06 ` Andrew Sayers [this message]
2025-06-11 13:06 ` [PATCH BlueZ v2 3/3] Revert "obexd: Support creating private system/session bus connections" Andrew Sayers
2025-06-11 14:50 ` [PATCH BlueZ v2 0/3] pbap: use the public DBus connection patchwork-bot+bluetooth
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=20250611131125.450039-3-kernel.org@pileofstuff.org \
--to=kernel.org@pileofstuff.org \
--cc=frederic.danis@collabora.com \
--cc=linux-bluetooth@vger.kernel.org \
--cc=luiz.dentz@gmail.com \
--cc=pav@iki.fi \
/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).