diff mbox series

Fix a logical error of workaround of listen failure

Message ID 69609765.5b65.18cf77eefe4.Coremail.zhuhai.mail@163.com
State Accepted
Headers show
Series Fix a logical error of workaround of listen failure | expand

Commit Message

朱海 Jan. 11, 2024, 7:49 a.m. UTC
when p2p->state == P2P_LISTEN_ONLY is true, 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 had met such error, the 'remain-on-channel' command failed, then the
function p2p_ext_listen_timeout just printed 'Operation in progress'
again and again, the listen was not started anymore.

Signed-off-by: zhuhai <zhuhai.mail@163.com>
---
 src/p2p/p2p.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)
--
2.42.0

Comments

Jouni Malinen Jan. 14, 2024, 7:30 p.m. UTC | #1
On Thu, Jan 11, 2024 at 03:49:00PM +0800, 朱海 wrote:
> when p2p->state == P2P_LISTEN_ONLY is true, 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 had met such error, the 'remain-on-channel' command failed, then the
> function p2p_ext_listen_timeout just printed 'Operation in progress'
> again and again, the listen was not started anymore.

Thanks, applied.
diff mbox series

Patch

diff --git a/src/p2p/p2p.c b/src/p2p/p2p.c
index 7e11abff4..1327a56b8 100644
--- a/src/p2p/p2p.c
+++ b/src/p2p/p2p.c
@@ -4662,15 +4662,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
@@ -4683,6 +4674,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;