diff options
author | Naveen Singh <nasingh@google.com> | 2016-03-17 17:33:15 -0700 |
---|---|---|
committer | Patrik Flykt <patrik.flykt@linux.intel.com> | 2016-03-22 11:25:47 +0200 |
commit | b0d56ee9f192642187d8b9f1142a4ff4fc11f49c (patch) | |
tree | aae3c89093dc0acc32020c24e5038454e35c6e9b | |
parent | 6091081903ce185a3c260ac41269a82ba3a81e59 (diff) | |
download | connman-b0d56ee9f192642187d8b9f1142a4ff4fc11f49c.tar.gz |
gsupplicant: Optimize AddNetwork Handler by avoiding D-Bus call.
In case network path is not NULL, network should only be removed
if the new network (to be added) is different from what is sitting
in wpa_supplicant. This would avoid two D-Bus calls: AddNetwork and
SelectNetwork.
-rw-r--r-- | gsupplicant/supplicant.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/gsupplicant/supplicant.c b/gsupplicant/supplicant.c index c8fbef66..4297557b 100644 --- a/gsupplicant/supplicant.c +++ b/gsupplicant/supplicant.c @@ -181,6 +181,7 @@ struct _GSupplicantInterface { GHashTable *bss_mapping; void *data; const char *pending_peer_path; + char * added_ssid; }; struct g_supplicant_bss { @@ -616,6 +617,7 @@ static void remove_interface(gpointer data) g_free(interface->wps_cred.key); g_free(interface->path); g_free(interface->network_path); + g_free(interface->added_ssid); g_free(interface->ifname); g_free(interface->driver); g_free(interface->bridge); @@ -4111,6 +4113,9 @@ static void interface_add_network_result(const char *error, interface->network_path = g_strdup(path); + g_free(interface->added_ssid); + interface->added_ssid = g_strdup(data->ssid->ssid); + supplicant_dbus_method_call(data->interface->path, SUPPLICANT_INTERFACE ".Interface", "SelectNetwork", interface_select_network_params, @@ -4708,6 +4713,17 @@ int g_supplicant_interface_connect(GSupplicantInterface *interface, g_free(data->path); dbus_free(data); + /* If this add network is for the same SSID for which + * wpa_supplicant already has a profile then do not need + * to add another profile. Only if the profile that needs + * to get added is different from what is there in wpa_s + * delete the current one. interface->added_ssid is populated + * once add network request is successful.*/ + + if (g_strcmp0(interface->added_ssid, ssid->ssid) == 0) { + return -EALREADY; + } + intf_data = dbus_malloc0(sizeof(*intf_data)); if (!intf_data) return -ENOMEM; @@ -4756,6 +4772,9 @@ static void network_remove_result(const char *error, g_free(data->interface->network_path); data->interface->network_path = NULL; + g_free(data->interface->added_ssid); + data->interface->added_ssid = NULL; + if (data->network_remove_in_progress == TRUE) { data->network_remove_in_progress = FALSE; connect_data = dbus_malloc0(sizeof(*connect_data)); |