From e847c8b4688c21a2f2e92fb21775cf9173e1751f Mon Sep 17 00:00:00 2001 From: lnlan Date: Mon, 28 Mar 2022 04:01:55 +0000 Subject: [PATCH] =?UTF-8?q?fix:=E4=BC=98=E5=8C=96=E4=BF=AE=E6=94=B9epoll?= =?UTF-8?q?=5Fcreate=E7=B3=BB=E7=BB=9F=E8=B0=83=E7=94=A8=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E5=92=8Cepoll=5Fcreate=E5=AE=9E=E7=8E=B0=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit re #I4STTF Signed-off-by: Kiita Change-Id: Ifec720eb5dd7aef8283875048d23b6a3d66b5436 --- fs/vfs/epoll/fs_epoll.c | 16 ++++++++-------- fs/vfs/include/epoll.h | 2 +- syscall/fs_syscall.c | 31 ++++++++++--------------------- 3 files changed, 19 insertions(+), 30 deletions(-) diff --git a/fs/vfs/epoll/fs_epoll.c b/fs/vfs/epoll/fs_epoll.c index 8591d612..822634f5 100644 --- a/fs/vfs/epoll/fs_epoll.c +++ b/fs/vfs/epoll/fs_epoll.c @@ -164,23 +164,23 @@ static VOID DoEpollClose(struct epoll_head *epHead) } /** - * epoll_create, + * epoll_create unsupported api + * + * epoll_create is implemented by calling epoll_create1, it's parameter 'size' is useless. + * + * epoll_create1, * The simple version of epoll does not use red-black trees, * so when fd is normal value (greater than 0), * actually allocated epoll can manage num of EPOLL_DEFAULT_SIZE * - * @param size: not actually used + * @param flags: not actually used * @return epoll fd */ -int epoll_create(int size) +int epoll_create1(int flags) { + (void)flags; int fd = -1; - if (size <= 0) { - set_errno(EINVAL); - return fd; - } - struct epoll_head *epHead = (struct epoll_head *)malloc(sizeof(struct epoll_head)); if (epHead == NULL) { set_errno(ENOMEM); diff --git a/fs/vfs/include/epoll.h b/fs/vfs/include/epoll.h index c6f6ff3a..e0aed193 100644 --- a/fs/vfs/include/epoll.h +++ b/fs/vfs/include/epoll.h @@ -72,7 +72,7 @@ struct epoll_event { epoll_data_t data; }; -int epoll_create(int size); +int epoll_create1(int flags); int epoll_close(int epfd); int epoll_ctl(int epfd, int op, int fd, struct epoll_event *ev); int epoll_wait(int epfd, FAR struct epoll_event *evs, int maxevents, int timeout); diff --git a/syscall/fs_syscall.c b/syscall/fs_syscall.c index 40d4c0c2..57e9f37c 100644 --- a/syscall/fs_syscall.c +++ b/syscall/fs_syscall.c @@ -2601,18 +2601,15 @@ int SysPselect6(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, return ret; } -int SysEpollCreate(int size) +static int DoEpollCreate1(int flags) { int ret; int procFd; - if (size <= 0) { - return -EINVAL; - } - - ret = epoll_create(size); + ret = epoll_create1(flags); if (ret < 0) { ret = -get_errno(); + return ret; } procFd = AllocAndAssocProcessFd((INTPTR)(ret), MIN_START_FD); @@ -2624,23 +2621,15 @@ int SysEpollCreate(int size) return procFd; } -int SysEpollCreate1(int flags) +int SysEpollCreate(int size) { - int ret; - int procFd; - - ret = epoll_create(flags); - if (ret < 0) { - ret = -get_errno(); - } - - procFd = AllocAndAssocProcessFd((INTPTR)(ret), MIN_START_FD); - if (procFd == -1) { - epoll_close(ret); - return -EMFILE; - } + (void)size; + return DoEpollCreate1(0); +} - return procFd; +int SysEpollCreate1(int flags) +{ + return DoEpollCreate1(flags); } int SysEpollCtl(int epfd, int op, int fd, struct epoll_event *ev) -- GitLab