[PATCH] p2p_supplicant: fix long_listen

Johannes Berg johannes
Thu Nov 25 21:31:44 PST 2010


From: Johannes Berg <johannes.berg at intel.com>

There are two issues with p2p_long_listen:
 1) max_remain_on_channel is assumed to be 5 seconds,
 2) if max_remain_on_channel is not a full multiple of
    seconds, accounting breaks.

Fix these by converting p2p_long_listen to ms and
tracking it according to max_remain_on_channel.

Signed-off-by: Johannes Berg <johannes.berg at intel.com>
---
I'm a bit confused by the fact that we potentially call p2p_listen_end()
multiple times when long listen is in effect, but that seems to be
intended?

 wpa_supplicant/p2p_supplicant.c |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

--- hostap.orig/wpa_supplicant/p2p_supplicant.c	2010-11-26 06:12:11.000000000 +0100
+++ hostap/wpa_supplicant/p2p_supplicant.c	2010-11-26 06:21:55.000000000 +0100
@@ -2916,7 +2916,7 @@ void wpas_p2p_cancel_remain_on_channel_c
 					  unsigned int freq)
 {
 	wpa_printf(MSG_DEBUG, "P2P: Cancel remain-on-channel callback "
-		   "(p2p_long_listen=%d pending_action_tx=%p)",
+		   "(p2p_long_listen=%dms pending_action_tx=%p)",
 		   wpa_s->p2p_long_listen, wpa_s->pending_action_tx);
 	wpa_s->off_channel_freq = 0;
 	if (p2p_listen_end(wpa_s->global->p2p, freq) > 0)
@@ -2924,10 +2924,10 @@ void wpas_p2p_cancel_remain_on_channel_c
 	if (wpa_s->pending_action_tx)
 		return;
 	if (wpa_s->p2p_long_listen > 0)
-		wpa_s->p2p_long_listen -= 5;
+		wpa_s->p2p_long_listen -= wpa_s->max_remain_on_chan;
 	if (wpa_s->p2p_long_listen > 0) {
 		wpa_printf(MSG_DEBUG, "P2P: Continuing long Listen state");
-		wpas_p2p_listen_start(wpa_s, wpa_s->p2p_long_listen * 1000);
+		wpas_p2p_listen_start(wpa_s, wpa_s->p2p_long_listen);
 	}
 }
 
@@ -3409,7 +3409,7 @@ int wpas_p2p_listen(struct wpa_supplican
 
 	res = wpas_p2p_listen_start(wpa_s, timeout * 1000);
 	if (res == 0 && timeout * 1000 > wpa_s->max_remain_on_chan) {
-		wpa_s->p2p_long_listen = timeout;
+		wpa_s->p2p_long_listen = timeout * 1000;
 		eloop_register_timeout(timeout, 0,
 				       wpas_p2p_long_listen_timeout,
 				       wpa_s, NULL);





More information about the Hostap mailing list