Do not set network index from PAN disconnect reply
authorSamuel Ortiz <sameo@linux.intel.com>
Tue, 6 Apr 2010 21:39:57 +0000 (23:39 +0200)
committerSamuel Ortiz <sameo@linux.intel.com>
Tue, 6 Apr 2010 21:45:12 +0000 (23:45 +0200)
There is no need to track the network's connected state through its index.
As a matter of fact, setting the network index to -1 on the PAN disconnect
path can triggers segmentation faults when powering the device off at the
same time.

plugins/bluetooth.c

index 9a43059..cec5e64 100644 (file)
@@ -131,9 +131,6 @@ static int pan_connect(struct connman_network *network)
        if (path == NULL)
                return -EINVAL;
 
-       if (connman_network_get_index(network) >= 0)
-               return -EISCONN;
-
        message = dbus_message_new_method_call(BLUEZ_SERVICE, path,
                                        BLUEZ_NETWORK_INTERFACE, CONNECT);
        if (message == NULL)
@@ -186,7 +183,6 @@ static void disconnect_reply(DBusPendingCall *call, void *user_data)
        }
 
        connman_network_set_connected(network, FALSE);
-       connman_network_set_index(network, -1);
 
 done:
        dbus_message_unref(reply);
@@ -205,9 +201,6 @@ static int pan_disconnect(struct connman_network *network)
        if (path == NULL)
                return -EINVAL;
 
-       if (connman_network_get_index(network) < 0)
-               return -ENOTCONN;
-
        message = dbus_message_new_method_call(BLUEZ_SERVICE, path,
                                        BLUEZ_NETWORK_INTERFACE, DISCONNECT);
        if (message == NULL)