1
0
Fork 0
mirror of https://github.com/albfan/miraclecast.git synced 2025-03-09 23:38:56 +00:00

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 <andrey.gusakov@cogentembedded.com>
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
This commit is contained in:
Andrey Gusakov 2014-07-29 15:53:34 +04:00 committed by David Herrmann
parent e79f08dd25
commit 204fa269e3

View file

@ -644,6 +644,9 @@ static void supplicant_peer_free(struct supplicant_peer *sp)
supplicant_peer_drop_group(sp); supplicant_peer_drop_group(sp);
peer_supplicant_stopped(sp->p); peer_supplicant_stopped(sp->p);
peer_free(sp->p); peer_free(sp->p);
/* free pending */
if (sp->s->pending == sp)
sp->s->pending = NULL;
free(sp->sta_mac); free(sp->sta_mac);
free(sp->remote_addr); free(sp->remote_addr);
@ -706,6 +709,9 @@ int supplicant_peer_connect(struct supplicant_peer *sp,
if (sp->g) if (sp->g)
return 0; return 0;
if (sp->s->pending && sp->s->pending != sp)
return log_ERR(-EALREADY);
if (!prov_type && !(prov_type = sp->prov)) if (!prov_type && !(prov_type = sp->prov))
prov_type = "pbc"; prov_type = "pbc";
if (!pin) if (!pin)
@ -1903,6 +1909,8 @@ int supplicant_p2p_start_scan(struct supplicant *s)
if (!s->running || !s->has_p2p) if (!s->running || !s->has_p2p)
return log_EINVAL(); return log_EINVAL();
s->pending = NULL;
/* /*
* This call is asynchronous. You can safely issue multiple of these * This call is asynchronous. You can safely issue multiple of these
* in parallel. You're supposed to track the "p2p_scanning" boolean * in parallel. You're supposed to track the "p2p_scanning" boolean