From abf9fbee30a1f524b659d8386e962c71e527bbf3 Mon Sep 17 00:00:00 2001 From: wangjianyu3 Date: Thu, 19 Jun 2025 21:15:24 +0800 Subject: [PATCH] system/fastboot: switch to epoll Switch from poll() to epoll(). Signed-off-by: wangjianyu3 --- system/fastboot/fastboot.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/system/fastboot/fastboot.c b/system/fastboot/fastboot.c index 67a01dd0d..c5afbb9a9 100644 --- a/system/fastboot/fastboot.c +++ b/system/fastboot/fastboot.c @@ -43,13 +43,13 @@ #include #include +#include #include #include #include #include #include #include -#include #include /**************************************************************************** @@ -980,14 +980,27 @@ static void fastboot_oem(FAR struct fastboot_ctx_s *ctx, FAR const char *arg) static void fastboot_command_loop(FAR struct fastboot_ctx_s *ctx) { + struct epoll_event ev[1]; + int epfd; + if (ctx->left > 0) { - struct pollfd fds[1]; + epfd = epoll_create(1); + if (epfd < 0) + { + fb_err("open epoll failed %d", errno); + return; + } - fds[0].fd = ctx->tran_fd[0]; - fds[0].events = POLLIN; + ev[0].events = EPOLLIN; + ev[0].data.ptr = ctx; + if (epoll_ctl(epfd, EPOLL_CTL_ADD, ctx->tran_fd[0], &ev[0]) < 0) + { + fb_err("err add poll %d", ctx->tran_fd[0]); + return; + } - if (poll(fds, 1, ctx->left) <= 0) + if (epoll_wait(epfd, ev, nitems(ev), ctx->left) <= 0) { return; }