From 9bf6bb654ff78efafe8cb4c4d55b6acaa0f53c27 Mon Sep 17 00:00:00 2001 From: Andrew Sayers Date: Tue, 29 Apr 2025 15:14:11 +0100 Subject: [PATCH] pbap: Support calling pbap_init() after pbap_exit() 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. --- obexd/client/pbap.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/obexd/client/pbap.c b/obexd/client/pbap.c index 2f234fadf..90f8bdc02 100644 --- a/obexd/client/pbap.c +++ b/obexd/client/pbap.c @@ -1485,8 +1485,20 @@ void pbap_exit(void) { DBG(""); - dbus_connection_unref(conn); - conn = NULL; + g_dbus_remove_watch(system_conn, listener_id); + + unregister_profile(); + + if (system_conn) { + dbus_connection_close(system_conn); + dbus_connection_unref(system_conn); + system_conn = NULL; + } + + if (conn) { + dbus_connection_unref(conn); + conn = NULL; + } obc_driver_unregister(&pbap); } -- 2.47.3