summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorDaniel Wagner <daniel.wagner@bmw-carit.de>2011-07-25 16:24:38 +0200
committerMarcel Holtmann <marcel@holtmann.org>2011-07-26 01:23:21 +0200
commitc8c5cd51ef7e1ec163423183ecd160a1e4e918b8 (patch)
tree4aac008eea51d549f79cabf08248d08793590b56 /plugins
parent2c349f0457259d9fa670b61525570723f7563bdd (diff)
downloadconnman-c8c5cd51ef7e1ec163423183ecd160a1e4e918b8.tar.gz
connman-c8c5cd51ef7e1ec163423183ecd160a1e4e918b8.tar.bz2
connman-c8c5cd51ef7e1ec163423183ecd160a1e4e918b8.zip
wifi: Fix network owner ship
Diffstat (limited to 'plugins')
-rw-r--r--plugins/wifi.c39
1 files changed, 27 insertions, 12 deletions
diff --git a/plugins/wifi.c b/plugins/wifi.c
index edea4e72..c5c0273d 100644
--- a/plugins/wifi.c
+++ b/plugins/wifi.c
@@ -61,6 +61,7 @@ struct wifi_data {
struct connman_device *device;
struct connman_network *network;
struct connman_network *pending_network;
+ GSList *networks;
GSupplicantInterface *interface;
GSupplicantState state;
connman_bool_t connected;
@@ -154,6 +155,22 @@ static int wifi_probe(struct connman_device *device)
return 0;
}
+static void remove_networks(struct connman_device *device,
+ struct wifi_data *wifi)
+{
+ GSList *list;
+
+ for (list = wifi->networks; list != NULL; list = list->next) {
+ struct connman_network *network = list->data;
+
+ connman_device_remove_network(device, network);
+ connman_network_unref(network);
+ }
+
+ g_slist_free(wifi->networks);
+ wifi->networks = NULL;
+}
+
static void wifi_remove(struct connman_device *device)
{
struct wifi_data *wifi = connman_device_get_data(device);
@@ -165,10 +182,7 @@ static void wifi_remove(struct connman_device *device)
iface_list = g_list_remove(iface_list, wifi);
- if (wifi->pending_network != NULL) {
- connman_network_unref(wifi->pending_network);
- wifi->pending_network = NULL;
- }
+ remove_networks(device, wifi);
connman_device_set_data(device, NULL);
connman_device_unref(wifi->device);
@@ -239,10 +253,10 @@ static int wifi_disable(struct connman_device *device)
wifi->connected = FALSE;
wifi->disconnecting = FALSE;
- if (wifi->pending_network != NULL) {
- connman_network_unref(wifi->pending_network);
+ if (wifi->pending_network != NULL)
wifi->pending_network = NULL;
- }
+
+ remove_networks(device, wifi);
ret = g_supplicant_interface_remove(wifi->interface,
interface_remove_callback,
@@ -429,9 +443,9 @@ static int network_connect(struct connman_network *network)
ssid_init(ssid, network);
if (wifi->disconnecting == TRUE)
- wifi->pending_network = connman_network_ref(network);
+ wifi->pending_network = network;
else {
- wifi->network = connman_network_ref(network);
+ wifi->network = network;
return g_supplicant_interface_connect(interface, ssid,
connect_callback, network);
@@ -455,8 +469,6 @@ static void disconnect_callback(int result, GSupplicantInterface *interface,
*/
if (result < 0)
connman_network_set_connected(wifi->network, FALSE);
-
- connman_network_unref(wifi->network);
}
wifi->network = NULL;
@@ -465,7 +477,6 @@ static void disconnect_callback(int result, GSupplicantInterface *interface,
if (wifi->pending_network != NULL) {
network_connect(wifi->pending_network);
- connman_network_unref(wifi->pending_network);
wifi->pending_network = NULL;
}
@@ -799,6 +810,8 @@ static void network_added(GSupplicantNetwork *supplicant_network)
connman_network_unref(network);
return;
}
+
+ wifi->networks = g_slist_append(wifi->networks, network);
}
if (name != NULL && name[0] != '\0')
@@ -838,6 +851,8 @@ static void network_removed(GSupplicantNetwork *network)
if (connman_network == NULL)
return;
+ wifi->networks = g_slist_remove(wifi->networks, connman_network);
+
connman_device_remove_network(wifi->device, connman_network);
connman_network_unref(connman_network);
}