未验证 提交 49d72afc 编写于 作者: O openharmony_ci 提交者: Gitee

!810 fix:优化修改epoll系统调用接口

Merge pull request !810 from Kiita/220224_epoll
......@@ -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);
......
......@@ -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);
......
......@@ -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)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册