]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
P2P: Fix a logical error of workaround of extended listen failure
author朱海 <zhuhai.mail@163.com>
Thu, 11 Jan 2024 07:49:00 +0000 (15:49 +0800)
committerJouni Malinen <j@w1.fi>
Sun, 14 Jan 2024 19:13:24 +0000 (21:13 +0200)
When p2p->state == P2P_LISTEN_ONLY, the statement before it
'p2p->cfg->is_p2p_in_progress(p2p->cfg->cb_ctx)' will be true, too, so
this function will print a message "Operation in progress" and return;
the workaround to handle listen failure will be never reached.

I met such an error when the 'remain-on-channel' command failed, then
the function p2p_ext_listen_timeout() just printed 'Operation in
progress' again and again, and the listen operation was not started
anymore.

Fixes: 0f1034e3889e ("P2P: Refrain from performing extended listen during P2P connection")
Signed-off-by: zhuhai <zhuhai.mail@163.com>
src/p2p/p2p.c

index 7b17eb908ee9b14f6ba71b89911d6aead860a279..bb1938dc31b92e73dd5e7c1be79e3a88329e7d5b 100644 (file)
@@ -4658,15 +4658,6 @@ static void p2p_ext_listen_timeout(void *eloop_ctx, void *timeout_ctx)
                                       p2p_ext_listen_timeout, p2p, NULL);
        }
 
-       if ((p2p->cfg->is_p2p_in_progress &&
-            p2p->cfg->is_p2p_in_progress(p2p->cfg->cb_ctx)) ||
-           (p2p->pending_action_state == P2P_PENDING_PD &&
-            p2p->pd_retries > 0)) {
-               p2p_dbg(p2p, "Operation in progress - skip Extended Listen timeout (%s)",
-                       p2p_state_txt(p2p->state));
-               return;
-       }
-
        if (p2p->state == P2P_LISTEN_ONLY && p2p->ext_listen_only) {
                /*
                 * This should not really happen, but it looks like the Listen
@@ -4679,6 +4670,15 @@ static void p2p_ext_listen_timeout(void *eloop_ctx, void *timeout_ctx)
                p2p_set_state(p2p, P2P_IDLE);
        }
 
+       if ((p2p->cfg->is_p2p_in_progress &&
+            p2p->cfg->is_p2p_in_progress(p2p->cfg->cb_ctx)) ||
+           (p2p->pending_action_state == P2P_PENDING_PD &&
+            p2p->pd_retries > 0)) {
+               p2p_dbg(p2p, "Operation in progress - skip Extended Listen timeout (%s)",
+                       p2p_state_txt(p2p->state));
+               return;
+       }
+
        if (p2p->state != P2P_IDLE) {
                p2p_dbg(p2p, "Skip Extended Listen timeout in active state (%s)", p2p_state_txt(p2p->state));
                return;