]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
P2P: Avoid resetting pending_listen_freq if p2p_listen is pending
authorJithu Jance <jithu@broadcom.com>
Thu, 22 May 2014 06:55:53 +0000 (12:25 +0530)
committerJouni Malinen <j@w1.fi>
Thu, 22 May 2014 13:29:36 +0000 (16:29 +0300)
If p2p_listen is called while previous listen command's
remain_on_channel event is pending, the p2p_listen would fail
and it used to clear pending_listen_freq. Now when the remain-
on-channel event comes from the driver, the pending_listen_freq
doesn't match and gets ignored. This was leading to a case
where listen state was getting stuck (in case of WAIT_PEER_CONNECT
state).

Signed-off-by: Jithu Jance <jithu@broadcom.com>
src/p2p/p2p.c

index c2f8d9b10cdc4e37e981c1e048e4221c1a59d598..1a190414b07bf33e937882c6d55b0204fb77907e 100644 (file)
@@ -238,6 +238,12 @@ static void p2p_listen_in_find(struct p2p_data *p2p, int dev_disc)
        p2p_dbg(p2p, "Starting short listen state (state=%s)",
                p2p_state_txt(p2p->state));
 
+       if (p2p->pending_listen_freq) {
+               /* We have a pending p2p_listen request */
+               p2p_dbg(p2p, "p2p_listen command pending already");
+               return;
+       }
+
        freq = p2p_channel_to_freq(p2p->cfg->reg_class, p2p->cfg->channel);
        if (freq < 0) {
                p2p_dbg(p2p, "Unknown regulatory class/channel");
@@ -260,14 +266,14 @@ static void p2p_listen_in_find(struct p2p_data *p2p, int dev_disc)
                return;
        }
 
-       p2p->pending_listen_freq = freq;
-       p2p->pending_listen_sec = 0;
-       p2p->pending_listen_usec = 1024 * tu;
-
        ies = p2p_build_probe_resp_ies(p2p);
        if (ies == NULL)
                return;
 
+       p2p->pending_listen_freq = freq;
+       p2p->pending_listen_sec = 0;
+       p2p->pending_listen_usec = 1024 * tu;
+
        if (p2p->cfg->start_listen(p2p->cfg->cb_ctx, freq, 1024 * tu / 1000,
                    ies) < 0) {
                p2p_dbg(p2p, "Failed to start listen mode");
@@ -284,13 +290,18 @@ int p2p_listen(struct p2p_data *p2p, unsigned int timeout)
 
        p2p_dbg(p2p, "Going to listen(only) state");
 
+       if (p2p->pending_listen_freq) {
+               /* We have a pending p2p_listen request */
+               p2p_dbg(p2p, "p2p_listen command pending already");
+               return -1;
+       }
+
        freq = p2p_channel_to_freq(p2p->cfg->reg_class, p2p->cfg->channel);
        if (freq < 0) {
                p2p_dbg(p2p, "Unknown regulatory class/channel");
                return -1;
        }
 
-       p2p->pending_listen_freq = freq;
        p2p->pending_listen_sec = timeout / 1000;
        p2p->pending_listen_usec = (timeout % 1000) * 1000;
 
@@ -308,6 +319,8 @@ int p2p_listen(struct p2p_data *p2p, unsigned int timeout)
        if (ies == NULL)
                return -1;
 
+       p2p->pending_listen_freq = freq;
+
        if (p2p->cfg->start_listen(p2p->cfg->cb_ctx, freq, timeout, ies) < 0) {
                p2p_dbg(p2p, "Failed to start listen mode");
                p2p->pending_listen_freq = 0;
@@ -1116,6 +1129,7 @@ void p2p_stop_listen(struct p2p_data *p2p)
 
 void p2p_stop_find(struct p2p_data *p2p)
 {
+       p2p->pending_listen_freq = 0;
        p2p_stop_find_for_freq(p2p, 0);
 }