Re: [PATCH BlueZ 1/4] pbap: Support calling pbap_init() after pbap_exit()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



ke, 2025-04-23 kello 17:33 +0100, Andrew Sayers kirjoitti:
> pbap_exit() didn't previously unregister itself thoroughly.  That
> was fine if it was only called when the service was about to exit,
> because everything was implicitly unregistered when the process ended.
> But we need to be more scrupulous if this can be called throughout
> the program's lifecycle.
> 
> Send the UnregisterProfile message directly from pbap_exit(),
> then call unregister_profile().
> 
> The UnregisterProfile message can't be sent directly from
> unregister_profile(), because that also needs to be called when
> register_profile() fails halfway through.
> 
> Signed-off-by: Andrew Sayers <kernel.org@xxxxxxxxxxxxxxx>
> ---
>  obexd/client/pbap.c | 20 ++++++++++++++++++++
>  1 file changed, 20 insertions(+)
> 
> diff --git a/obexd/client/pbap.c b/obexd/client/pbap.c
> index 2f234fadf..e2a3c1b90 100644
> --- a/obexd/client/pbap.c
> +++ b/obexd/client/pbap.c
> @@ -1483,8 +1483,28 @@ int pbap_init(void)
>  
>  void pbap_exit(void)
>  {
> +	DBusMessage *msg;
> +	DBusMessageIter iter;
> +	char *uuid = PBAP_CLIENT_UUID;
> +
>  	DBG("");
>  
> +	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");

It was observed in Pipewire that calling UnregisterProfile on exit may
result to long delays on system shutdown, where bluetoothd may be
shutting down at the same time.

IIRC bluetoothd unregisters the profile automatically if you shutdown
the DBus connection, which may be a faster way to teardown.

> +
> +	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);
> +
> +	unregister_profile();
> +
>  	dbus_connection_unref(conn);
>  	conn = NULL;
>  

-- 
Pauli Virtanen





[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux