From 34ade7a0b64a59db7529b3d785228d4a89d7dbe0 Mon Sep 17 00:00:00 2001 From: Zhe Weng Date: Fri, 30 Dec 2022 15:01:26 +0800 Subject: [PATCH] net/devif: fix devif_poll loop logic Previously, the devif_poll works in this flow: devif_poll_xx -> bstop = callback -> continue if !bstop -> poll another Now we split the polling and callback, so it should work like: devif_poll_connections -> return true if callback need to be called -> bstop = callback -> loop if !bstop -> poll again Conditions: poll_connections == 0, d_len == 0, break, return 0 poll_connections == 1, d_len == 0, break, return 1 (other stop case, don't callback) poll_connections == 1, d_len > 0, callback == 1, break, return 1 poll_connections == 1, d_len > 0, callback == 0, loop Signed-off-by: Zhe Weng --- net/devif/devif_poll.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/net/devif/devif_poll.c b/net/devif/devif_poll.c index 89567a187a..4b77fbe218 100644 --- a/net/devif/devif_poll.c +++ b/net/devif/devif_poll.c @@ -964,8 +964,14 @@ int devif_poll(FAR struct net_driver_s *dev, devif_poll_callback_t callback) } } } + else + { + /* Not stopped by devif_poll_callback, just stop and return bstop */ + + break; + } } - while (bstop); + while (!bstop); /* Device polling completed, release iob */