This is an automated email from the ASF dual-hosted git repository. xiaoxiang pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx-apps.git
commit abf9fbee30a1f524b659d8386e962c71e527bbf3 Author: wangjianyu3 <wangjian...@xiaomi.com> AuthorDate: Thu Jun 19 21:15:24 2025 +0800 system/fastboot: switch to epoll Switch from poll() to epoll(). Signed-off-by: wangjianyu3 <wangjian...@xiaomi.com> --- 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 <netinet/in.h> #include <sys/boardctl.h> +#include <sys/epoll.h> #include <sys/ioctl.h> #include <sys/param.h> #include <sys/socket.h> #include <sys/stat.h> #include <sys/statfs.h> #include <sys/types.h> -#include <sys/poll.h> #include <sys/wait.h> /**************************************************************************** @@ -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; }