mirror of
https://git.proxmox.com/git/mirror_lxc
synced 2025-08-14 17:12:14 +00:00
Simplify the mainloop
The number of fds passed to epoll is just a hint for the kernel. In our case, we know this is often 2, let's remove this parameter from lxc_mainloop_open and cleanup the code around the caller of this function. Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
This commit is contained in:
parent
ded1d23faa
commit
a9e61274bc
@ -154,12 +154,13 @@ int lxc_mainloop_del_handler(struct lxc_epoll_descr *descr, int fd)
|
||||
return -1;
|
||||
}
|
||||
|
||||
int lxc_mainloop_open(int size, struct lxc_epoll_descr *descr)
|
||||
int lxc_mainloop_open(struct lxc_epoll_descr *descr)
|
||||
{
|
||||
descr->nfds = 0;
|
||||
descr->ev = NULL;
|
||||
|
||||
descr->epfd = epoll_create(size);
|
||||
/* hint value passed to epoll create */
|
||||
descr->epfd = epoll_create(2);
|
||||
if (descr->epfd < 0)
|
||||
return -1;
|
||||
|
||||
|
@ -40,6 +40,6 @@ extern int lxc_mainloop_add_handler(struct lxc_epoll_descr *descr, int fd,
|
||||
|
||||
extern int lxc_mainloop_del_handler(struct lxc_epoll_descr *descr, int fd);
|
||||
|
||||
extern int lxc_mainloop_open(int size, struct lxc_epoll_descr *descr);
|
||||
extern int lxc_mainloop_open(struct lxc_epoll_descr *descr);
|
||||
|
||||
extern int lxc_mainloop_close(struct lxc_epoll_descr *descr);
|
||||
|
@ -152,15 +152,10 @@ int lxc_poll(const char *name, struct lxc_handler *handler)
|
||||
{
|
||||
int sigfd = handler->sigfd;
|
||||
int pid = handler->pid;
|
||||
const struct lxc_tty_info *tty_info = &handler->tty_info;
|
||||
|
||||
int nfds, ret = -1;
|
||||
int ret = -1;
|
||||
struct lxc_epoll_descr descr;
|
||||
|
||||
/* nb tty + sigfd + command service */
|
||||
nfds = tty_info->nbtty + 2;
|
||||
|
||||
if (lxc_mainloop_open(nfds, &descr)) {
|
||||
if (lxc_mainloop_open(&descr)) {
|
||||
ERROR("failed to create mainloop");
|
||||
goto out_sigfd;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user