This is an automated email from the ASF dual-hosted git repository.

jerpelea pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx-apps.git

commit 4b5af957ac68edd016f642e00e67cc60ba843e4b
Author: wangjianyu3 <[email protected]>
AuthorDate: Tue Jun 24 18:35:02 2025 +0800

    system/fastboot: remove interest and close epoll
    
    Remove fds from the interest list and close epoll if need.
    
    Signed-off-by: wangjianyu3 <[email protected]>
---
 system/fastboot/fastboot.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/system/fastboot/fastboot.c b/system/fastboot/fastboot.c
index 569d5c961..190040e55 100644
--- a/system/fastboot/fastboot.c
+++ b/system/fastboot/fastboot.c
@@ -1008,7 +1008,7 @@ static void fastboot_command_loop(FAR struct 
fastboot_ctx_s *ctx,
       if (epoll_ctl(epfd, EPOLL_CTL_ADD, c->tran_fd[0], &ev[n]) < 0)
         {
           fb_err("err add poll %d", c->tran_fd[0]);
-          return;
+          goto epoll_close;
         }
     }
 
@@ -1016,7 +1016,7 @@ static void fastboot_command_loop(FAR struct 
fastboot_ctx_s *ctx,
     {
       if (epoll_wait(epfd, ev, nitems(ev), ctx->left) <= 0)
         {
-          return;
+          goto epoll_close;
         }
     }
 
@@ -1061,6 +1061,14 @@ static void fastboot_command_loop(FAR struct 
fastboot_ctx_s *ctx,
             }
         }
     }
+
+epoll_close:
+  while (--c >= ctx)
+    {
+      epoll_ctl(epfd, EPOLL_CTL_DEL, c->tran_fd[0], NULL);
+    }
+
+  close(epfd);
 }
 
 static void fastboot_publish(FAR struct fastboot_ctx_s *ctx,

Reply via email to