From: Patrik Flykt <[email protected]>
Up the reference count on struct connman_network when
network_connect() is called and release it in the callback.
Also track wifi->pending_network usage.
---
plugins/wifi.c | 12 ++++++++++--
1 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/plugins/wifi.c b/plugins/wifi.c
index e462639..92fcd37 100644
--- a/plugins/wifi.c
+++ b/plugins/wifi.c
@@ -254,8 +254,10 @@ static int wifi_disable(struct connman_device *device)
wifi->connected = FALSE;
wifi->disconnecting = FALSE;
- if (wifi->pending_network != NULL)
+ if (wifi->pending_network != NULL) {
+ connman_network_unref(wifi->pending_network);
wifi->pending_network = NULL;
+ }
remove_networks(device, wifi);
@@ -367,6 +369,7 @@ static void connect_callback(int result,
GSupplicantInterface *interface,
connman_network_set_error(network,
CONNMAN_NETWORK_ERROR_CONFIGURE_FAIL);
}
+ connman_network_unref(network);
}
static GSupplicantSecurity network_security(const char *security)
@@ -455,6 +458,7 @@ static int network_connect(struct connman_network *network)
struct wifi_data *wifi;
GSupplicantInterface *interface;
GSupplicantSSID *ssid;
+ int err;
DBG("network %p", network);
@@ -473,13 +477,16 @@ static int network_connect(struct connman_network
*network)
ssid_init(ssid, network);
+ connman_network_ref(network);
if (wifi->disconnecting == TRUE)
wifi->pending_network = network;
else {
wifi->network = network;
- return g_supplicant_interface_connect(interface, ssid,
+ err = g_supplicant_interface_connect(interface, ssid,
connect_callback, network);
+ if (err != -EINPROGRESS)
+ connman_network_unref(network);
}
return -EINPROGRESS;
@@ -508,6 +515,7 @@ 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;
}
--
1.7.2.5
_______________________________________________
connman mailing list
[email protected]
http://lists.connman.net/listinfo/connman