OSDN Git Service

obexd/bluetooth: Fix error on register_profile
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Tue, 10 Sep 2013 11:38:55 +0000 (14:38 +0300)
committerLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Tue, 10 Sep 2013 11:48:35 +0000 (14:48 +0300)
The error happens whenever RegisterProfile fails the interface is not
unregistered causing any subsequent call to register_profile function
to fail:

obexd[944]: D-Bus failed to register /org/bluez/obex/00005005_0000_1000_8000_0002ee000001
obexd[944]: bluetooth: Failed to register profile (null)

obexd/plugins/bluetooth.c

index 10f5e4f..6f6ace9 100644 (file)
@@ -185,6 +185,14 @@ static const GDBusMethodTable profile_methods[] = {
        { }
 };
 
+static void unregister_profile(struct bluetooth_profile *profile)
+{
+       g_dbus_unregister_interface(connection, profile->path,
+                                               "org.bluez.Profile1");
+       g_free(profile->path);
+       profile->path = NULL;
+}
+
 static void register_profile_reply(DBusPendingCall *call, void *user_data)
 {
        struct bluetooth_profile *profile = user_data;
@@ -198,8 +206,7 @@ static void register_profile_reply(DBusPendingCall *call, void *user_data)
                goto done;
        }
 
-       g_free(profile->path);
-       profile->path = NULL;
+       unregister_profile(profile);
 
        error("bluetooth: RequestProfile error: %s, %s", derr.name,
                                                                derr.message);
@@ -208,14 +215,6 @@ done:
        dbus_message_unref(reply);
 }
 
-static void unregister_profile(struct bluetooth_profile *profile)
-{
-       g_dbus_unregister_interface(connection, profile->path,
-                                               "org.bluez.Profile1");
-       g_free(profile->path);
-       profile->path = NULL;
-}
-
 static void profile_free(void *data)
 {
        struct bluetooth_profile *profile = data;