[PATCH 2/2] P2P: Refactor common deinit in go_neg_completed
Eduardo Abinader
eduardo.abinader
Sat May 3 09:42:53 PDT 2014
Reuse common code for cancel timeout and formation failure
notification.
---
wpa_supplicant/p2p_supplicant.c | 19 ++++++++++++-------
1 file changed, 12 insertions(+), 7 deletions(-)
diff --git a/wpa_supplicant/p2p_supplicant.c b/wpa_supplicant/p2p_supplicant.c
index 62e628d..21c00ab 100644
--- a/wpa_supplicant/p2p_supplicant.c
+++ b/wpa_supplicant/p2p_supplicant.c
@@ -1577,6 +1577,7 @@ void wpas_p2p_ap_setup_failed(struct wpa_supplicant *wpa_s)
static void wpas_go_neg_completed(void *ctx, struct p2p_go_neg_results *res)
{
struct wpa_supplicant *wpa_s = ctx;
+ int failed_negotiation = 0;
if (wpa_s->off_channel_freq || wpa_s->roc_waiting_drv_freq) {
wpa_drv_cancel_remain_on_channel(wpa_s);
@@ -1590,9 +1591,8 @@ static void wpas_go_neg_completed(void *ctx, struct p2p_go_neg_results *res)
res->status);
wpas_notify_p2p_go_neg_completed(wpa_s, res);
wpas_p2p_remove_pending_group_interface(wpa_s);
- eloop_cancel_timeout(wpas_p2p_long_listen_timeout, wpa_s, NULL);
- wpas_p2p_group_formation_failed(wpa_s);
- return;
+ failed_negotiation = 1;
+ goto formation_failed;
}
if (wpa_s->p2p_go_ht40)
@@ -1628,10 +1628,8 @@ static void wpas_go_neg_completed(void *ctx, struct p2p_go_neg_results *res)
wpas_p2p_init_group_interface(wpa_s, res->role_go);
if (group_wpa_s == NULL) {
wpas_p2p_remove_pending_group_interface(wpa_s);
- eloop_cancel_timeout(wpas_p2p_long_listen_timeout,
- wpa_s, NULL);
- wpas_p2p_group_formation_failed(wpa_s);
- return;
+ failed_negotiation = 1;
+ goto formation_failed;
}
if (group_wpa_s != wpa_s) {
os_memcpy(group_wpa_s->p2p_pin, wpa_s->p2p_pin,
@@ -1657,8 +1655,15 @@ static void wpas_go_neg_completed(void *ctx, struct p2p_go_neg_results *res)
}
wpa_s->p2p_long_listen = 0;
+
+formation_failed:
eloop_cancel_timeout(wpas_p2p_long_listen_timeout, wpa_s, NULL);
+ if (failed_negotiation) {
+ wpas_p2p_group_formation_failed(wpa_s);
+ return;
+ }
+
eloop_cancel_timeout(wpas_p2p_group_formation_timeout, wpa_s, NULL);
eloop_register_timeout(15 + res->peer_config_timeout / 100,
(res->peer_config_timeout % 100) * 10000,
--
1.9.1
More information about the Hostap
mailing list