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:
Daniel Lezcano 2009-10-07 16:06:09 +02:00
parent ded1d23faa
commit a9e61274bc
3 changed files with 6 additions and 10 deletions

View File

@ -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;

View File

@ -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);

View File

@ -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;
}