Just to avoid an amount of p2p_call, if another is
already taking place.
---
 gsupplicant/gsupplicant.h | 2 ++
 gsupplicant/supplicant.c  | 8 ++++++++
 plugins/wifi.c            | 8 +++++++-
 3 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/gsupplicant/gsupplicant.h b/gsupplicant/gsupplicant.h
index 207e281..1e9812e 100644
--- a/gsupplicant/gsupplicant.h
+++ b/gsupplicant/gsupplicant.h
@@ -268,6 +268,8 @@ int 
g_supplicant_interface_set_p2p_device_config(GSupplicantInterface *interface
 GSupplicantPeer *g_supplicant_interface_peer_lookup(GSupplicantInterface 
*interface,
                                                const char *identifier);
 
+bool g_supplicant_interface_is_p2p_finding(GSupplicantInterface *interface);
+
 /* Network and Peer API */
 struct _GSupplicantNetwork;
 struct _GSupplicantGroup;
diff --git a/gsupplicant/supplicant.c b/gsupplicant/supplicant.c
index f188d0c..1d5c813 100644
--- a/gsupplicant/supplicant.c
+++ b/gsupplicant/supplicant.c
@@ -4647,6 +4647,14 @@ int g_supplicant_interface_p2p_find(GSupplicantInterface 
*interface,
        return ret;
 }
 
+bool g_supplicant_interface_is_p2p_finding(GSupplicantInterface *interface)
+{
+       if (!interface)
+               return false;
+
+       return interface->p2p_finding;
+}
+
 int g_supplicant_interface_p2p_stop_find(GSupplicantInterface *interface)
 {
        if (!interface->p2p_finding)
diff --git a/plugins/wifi.c b/plugins/wifi.c
index f741bec..cd13fee 100644
--- a/plugins/wifi.c
+++ b/plugins/wifi.c
@@ -1376,7 +1376,7 @@ error:
 
 static int p2p_find(struct connman_device *device)
 {
-       struct wifi_data *wifi = connman_device_get_data(device);
+       struct wifi_data *wifi;
        int ret;
 
        DBG("");
@@ -1384,11 +1384,17 @@ static int p2p_find(struct connman_device *device)
        if (!p2p_technology)
                return -ENOTSUP;
 
+       wifi = connman_device_get_data(device);
+
+       if (g_supplicant_interface_is_p2p_finding(wifi->interface))
+               return -EALREADY;
+
        reset_autoscan(device);
        connman_device_ref(device);
 
        ret = g_supplicant_interface_p2p_find(wifi->interface,
                                                p2p_find_callback, device);
+
        if (ret) {
                connman_device_unref(device);
                start_autoscan(device);
-- 
1.9.1

_______________________________________________
connman mailing list
[email protected]
https://lists.connman.net/mailman/listinfo/connman

Reply via email to