From: Daniel Lezcano Date: Wed, 7 Oct 2009 14:06:09 +0000 (+0200) Subject: Simplify the mainloop X-Git-Tag: lxc_0_6_4~74 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a9e61274bc2c316c4dbded00d9b75ff6419f42d6;p=thirdparty%2Flxc.git 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 --- diff --git a/src/lxc/mainloop.c b/src/lxc/mainloop.c index c96be7d84..97673bb93 100644 --- a/src/lxc/mainloop.c +++ b/src/lxc/mainloop.c @@ -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; diff --git a/src/lxc/mainloop.h b/src/lxc/mainloop.h index 5ee02280f..aa17eb5b8 100644 --- a/src/lxc/mainloop.h +++ b/src/lxc/mainloop.h @@ -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); diff --git a/src/lxc/start.c b/src/lxc/start.c index b7c8903a6..8826b8194 100644 --- a/src/lxc/start.c +++ b/src/lxc/start.c @@ -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; }