Patchwork [2/2] P2P: Refactor common deinit in go_neg_completed

login
register
mail settings
Submitter Eduardo Abinader
Date May 11, 2014, 4:54 p.m.
Message ID <1399827284-4893-2-git-send-email-eduardo.abinader@openbossa.org>
Download mbox | patch
Permalink /patch/347801/
State New
Headers show

Comments

Eduardo Abinader - May 11, 2014, 4:54 p.m.
Reuse common code for cancel timeout and formation failure
notification.

Signed-off-by: Eduardo Abinader <eduardo.abinader@openbossa.org>
---
 wpa_supplicant/p2p_supplicant.c | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)

Patch

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,