!810 fix:优化修改epoll系统调用接口
Merge pull request !810 from Kiita/220224_epoll
This commit is contained in:
commit
49d72afc8e
|
@ -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,
|
* The simple version of epoll does not use red-black trees,
|
||||||
* so when fd is normal value (greater than 0),
|
* so when fd is normal value (greater than 0),
|
||||||
* actually allocated epoll can manage num of EPOLL_DEFAULT_SIZE
|
* actually allocated epoll can manage num of EPOLL_DEFAULT_SIZE
|
||||||
*
|
*
|
||||||
* @param size: not actually used
|
* @param flags: not actually used
|
||||||
* @return epoll fd
|
* @return epoll fd
|
||||||
*/
|
*/
|
||||||
int epoll_create(int size)
|
int epoll_create1(int flags)
|
||||||
{
|
{
|
||||||
|
(void)flags;
|
||||||
int fd = -1;
|
int fd = -1;
|
||||||
|
|
||||||
if (size <= 0) {
|
|
||||||
set_errno(EINVAL);
|
|
||||||
return fd;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct epoll_head *epHead = (struct epoll_head *)malloc(sizeof(struct epoll_head));
|
struct epoll_head *epHead = (struct epoll_head *)malloc(sizeof(struct epoll_head));
|
||||||
if (epHead == NULL) {
|
if (epHead == NULL) {
|
||||||
set_errno(ENOMEM);
|
set_errno(ENOMEM);
|
||||||
|
|
|
@ -72,7 +72,7 @@ struct epoll_event {
|
||||||
epoll_data_t data;
|
epoll_data_t data;
|
||||||
};
|
};
|
||||||
|
|
||||||
int epoll_create(int size);
|
int epoll_create1(int flags);
|
||||||
int epoll_close(int epfd);
|
int epoll_close(int epfd);
|
||||||
int epoll_ctl(int epfd, int op, int fd, struct epoll_event *ev);
|
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);
|
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;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int SysEpollCreate(int size)
|
static int DoEpollCreate1(int flags)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
int procFd;
|
int procFd;
|
||||||
|
|
||||||
if (size <= 0) {
|
ret = epoll_create1(flags);
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = epoll_create(size);
|
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
ret = -get_errno();
|
ret = -get_errno();
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
procFd = AllocAndAssocProcessFd((INTPTR)(ret), MIN_START_FD);
|
procFd = AllocAndAssocProcessFd((INTPTR)(ret), MIN_START_FD);
|
||||||
|
@ -2624,23 +2621,15 @@ int SysEpollCreate(int size)
|
||||||
return procFd;
|
return procFd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int SysEpollCreate(int size)
|
||||||
|
{
|
||||||
|
(void)size;
|
||||||
|
return DoEpollCreate1(0);
|
||||||
|
}
|
||||||
|
|
||||||
int SysEpollCreate1(int flags)
|
int SysEpollCreate1(int flags)
|
||||||
{
|
{
|
||||||
int ret;
|
return DoEpollCreate1(flags);
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
return procFd;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int SysEpollCtl(int epfd, int op, int fd, struct epoll_event *ev)
|
int SysEpollCtl(int epfd, int op, int fd, struct epoll_event *ev)
|
||||||
|
|
Loading…
Reference in New Issue