From 204fa269e3f15a36fd718c1d2e10828a25fdde95 Mon Sep 17 00:00:00 2001 From: Andrey Gusakov Date: Tue, 29 Jul 2014 15:53:34 +0400 Subject: [PATCH] wifi: do not start new connections if one is already pending If there is already a connection pending, don't start a new one. Unfortunately, wpa_supplicant is unable to deal with this so we have to enforce this.. Yuck! We also reset the pending state during P2P_FIND now, this enables API users to reset failed connections that wpa_supplicant was unable to close (yeah, beacuse it's so hard to write proper APIs.. *sigh*). Signed-off-by: Andrey Gusakov Signed-off-by: David Herrmann --- src/wifi/wifid-supplicant.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/wifi/wifid-supplicant.c b/src/wifi/wifid-supplicant.c index bb18cef..7fe3da6 100644 --- a/src/wifi/wifid-supplicant.c +++ b/src/wifi/wifid-supplicant.c @@ -644,6 +644,9 @@ static void supplicant_peer_free(struct supplicant_peer *sp) supplicant_peer_drop_group(sp); peer_supplicant_stopped(sp->p); peer_free(sp->p); + /* free pending */ + if (sp->s->pending == sp) + sp->s->pending = NULL; free(sp->sta_mac); free(sp->remote_addr); @@ -706,6 +709,9 @@ int supplicant_peer_connect(struct supplicant_peer *sp, if (sp->g) return 0; + if (sp->s->pending && sp->s->pending != sp) + return log_ERR(-EALREADY); + if (!prov_type && !(prov_type = sp->prov)) prov_type = "pbc"; if (!pin) @@ -1903,6 +1909,8 @@ int supplicant_p2p_start_scan(struct supplicant *s) if (!s->running || !s->has_p2p) return log_EINVAL(); + s->pending = NULL; + /* * This call is asynchronous. You can safely issue multiple of these * in parallel. You're supposed to track the "p2p_scanning" boolean