Skip to content

Commit abf9fbe

Browse files
JianyuWang0623xiaoxiang781216
authored andcommitted
system/fastboot: switch to epoll
Switch from poll() to epoll(). Signed-off-by: wangjianyu3 <[email protected]>
1 parent e23ba48 commit abf9fbe

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

system/fastboot/fastboot.c

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,13 @@
4343

4444
#include <netinet/in.h>
4545
#include <sys/boardctl.h>
46+
#include <sys/epoll.h>
4647
#include <sys/ioctl.h>
4748
#include <sys/param.h>
4849
#include <sys/socket.h>
4950
#include <sys/stat.h>
5051
#include <sys/statfs.h>
5152
#include <sys/types.h>
52-
#include <sys/poll.h>
5353
#include <sys/wait.h>
5454

5555
/****************************************************************************
@@ -980,14 +980,27 @@ static void fastboot_oem(FAR struct fastboot_ctx_s *ctx, FAR const char *arg)
980980

981981
static void fastboot_command_loop(FAR struct fastboot_ctx_s *ctx)
982982
{
983+
struct epoll_event ev[1];
984+
int epfd;
985+
983986
if (ctx->left > 0)
984987
{
985-
struct pollfd fds[1];
988+
epfd = epoll_create(1);
989+
if (epfd < 0)
990+
{
991+
fb_err("open epoll failed %d", errno);
992+
return;
993+
}
986994

987-
fds[0].fd = ctx->tran_fd[0];
988-
fds[0].events = POLLIN;
995+
ev[0].events = EPOLLIN;
996+
ev[0].data.ptr = ctx;
997+
if (epoll_ctl(epfd, EPOLL_CTL_ADD, ctx->tran_fd[0], &ev[0]) < 0)
998+
{
999+
fb_err("err add poll %d", ctx->tran_fd[0]);
1000+
return;
1001+
}
9891002

990-
if (poll(fds, 1, ctx->left) <= 0)
1003+
if (epoll_wait(epfd, ev, nitems(ev), ctx->left) <= 0)
9911004
{
9921005
return;
9931006
}

0 commit comments

Comments
 (0)