]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
add epoll events to mainloop callback handlers
authorDwight Engen <dwight.engen@oracle.com>
Fri, 6 Dec 2013 20:36:44 +0000 (15:36 -0500)
committerStéphane Graber <stgraber@ubuntu.com>
Fri, 6 Dec 2013 21:03:20 +0000 (16:03 -0500)
Adding the epoll events allows the handler to determine what events
happened on the fd.

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
src/lxc/commands.c
src/lxc/console.c
src/lxc/lxc_monitord.c
src/lxc/lxcutmp.c
src/lxc/mainloop.c
src/lxc/mainloop.h
src/lxc/start.c

index 63adaf56cbb1f601098c345735feee48ff732850..ae4ff1ec415a524a1a0c29e728dfb4d890a5ff6a 100644 (file)
@@ -752,7 +752,8 @@ static void lxc_cmd_fd_cleanup(int fd, struct lxc_handler *handler,
        process_unlock();
 }
 
-static int lxc_cmd_handler(int fd, void *data, struct lxc_epoll_descr *descr)
+static int lxc_cmd_handler(int fd, uint32_t events, void *data,
+                          struct lxc_epoll_descr *descr)
 {
        int ret;
        struct lxc_cmd_req req;
@@ -816,7 +817,8 @@ out_close:
        goto out;
 }
 
-static int lxc_cmd_accept(int fd, void *data, struct lxc_epoll_descr *descr)
+static int lxc_cmd_accept(int fd, uint32_t events, void *data,
+                         struct lxc_epoll_descr *descr)
 {
        int opt = 1, ret = -1, connection;
 
index d854dbb66eabe3061e1018c9c52c8a8daf322572..5d91f24f55f4041d22cba34ad3671c55a7976a8c 100644 (file)
@@ -109,7 +109,7 @@ void lxc_console_sigwinch(int sig)
        }
 }
 
-static int lxc_console_cb_sigwinch_fd(int fd, void *cbdata,
+static int lxc_console_cb_sigwinch_fd(int fd, uint32_t events, void *cbdata,
                                      struct lxc_epoll_descr *descr)
 {
        struct signalfd_siginfo siginfo;
@@ -211,7 +211,7 @@ static void lxc_console_sigwinch_fini(struct lxc_tty_state *ts)
        free(ts);
 }
 
-static int lxc_console_cb_con(int fd, void *data,
+static int lxc_console_cb_con(int fd, uint32_t events, void *data,
                              struct lxc_epoll_descr *descr)
 {
        struct lxc_console *console = (struct lxc_console *)data;
@@ -628,7 +628,7 @@ err:
 
 
 
-static int lxc_console_cb_tty_stdin(int fd, void *cbdata,
+static int lxc_console_cb_tty_stdin(int fd, uint32_t events, void *cbdata,
                                    struct lxc_epoll_descr *descr)
 {
        struct lxc_tty_state *ts = cbdata;
@@ -658,7 +658,7 @@ static int lxc_console_cb_tty_stdin(int fd, void *cbdata,
        return 0;
 }
 
-static int lxc_console_cb_tty_master(int fd, void *cbdata,
+static int lxc_console_cb_tty_master(int fd, uint32_t events, void *cbdata,
                                     struct lxc_epoll_descr *descr)
 {
        struct lxc_tty_state *ts = cbdata;
index 11936a915ca802c81804ed751fad8c2967962f83..381b2d6e767e7180f1b04d9d12007bf8ea484ab5 100644 (file)
@@ -130,7 +130,7 @@ static void lxc_monitord_sockfd_remove(struct lxc_monitor *mon, int fd) {
        mon->clientfds_cnt--;
 }
 
-static int lxc_monitord_sock_handler(int fd, void *data,
+static int lxc_monitord_sock_handler(int fd, uint32_t events, void *data,
                                     struct lxc_epoll_descr *descr)
 {
        struct lxc_monitor *mon = data;
@@ -139,7 +139,7 @@ static int lxc_monitord_sock_handler(int fd, void *data,
        return 0;
 }
 
-static int lxc_monitord_sock_accept(int fd, void *data,
+static int lxc_monitord_sock_accept(int fd, uint32_t events, void *data,
                                    struct lxc_epoll_descr *descr)
 {
        int ret,clientfd;
@@ -262,7 +262,7 @@ static void lxc_monitord_delete(struct lxc_monitor *mon)
        mon->clientfds_cnt = 0;
 }
 
-static int lxc_monitord_fifo_handler(int fd, void *data,
+static int lxc_monitord_fifo_handler(int fd, uint32_t events, void *data,
                                     struct lxc_epoll_descr *descr)
 {
        int ret,i;
index bfebe55f30cfd6ea34db5f84ff29189f9bffc55e..d4a180c6e684ffb7434546c3b63913340d481194 100644 (file)
@@ -134,14 +134,15 @@ typedef void (*lxc_mainloop_timer_t) (void *data);
 
 static int utmp_get_runlevel(struct lxc_utmp *utmp_data);
 static int utmp_get_ntasks(struct lxc_handler *handler);
-static int utmp_shutdown_handler(int fd, void *data,
+static int utmp_shutdown_handler(int fd, uint32_t events, void *data,
                                 struct lxc_epoll_descr *descr);
 static int lxc_utmp_add_timer(struct lxc_epoll_descr *descr,
                              lxc_mainloop_callback_t callback, void *data);
 static int lxc_utmp_del_timer(struct lxc_epoll_descr *descr,
                              struct lxc_utmp *utmp_data);
 
-static int utmp_handler(int fd, void *data, struct lxc_epoll_descr *descr)
+static int utmp_handler(int fd, uint32_t events, void *data,
+                       struct lxc_epoll_descr *descr)
 {
        struct inotify_event *ie;
        int size, ret, length;
@@ -387,7 +388,7 @@ out:
        return -1;
 }
 
-static int utmp_shutdown_handler(int fd, void *data,
+static int utmp_shutdown_handler(int fd, uint32_t events, void *data,
                                 struct lxc_epoll_descr *descr)
 {
        int ntasks;
index 9ba98ee0dd9e361bfabdf2bdedaa68f80cf37cc7..ec0c2525c612c711e7cce42d2b2c78f3543a72e1 100644 (file)
@@ -60,8 +60,8 @@ int lxc_mainloop(struct lxc_epoll_descr *descr, int timeout_ms)
 
                        /* If the handler returns a positive value, exit
                           the mainloop */
-                       if (handler->callback(handler->fd, handler->data,
-                                             descr) > 0)
+                       if (handler->callback(handler->fd, events[i].events,
+                                             handler->data, descr) > 0)
                                return 0;
                }
 
index 217a58f32b1eac1fc10c6a37567697e29f118318..21ef577440ef8a3ceee1e1cb0e2afce795f64f64 100644 (file)
@@ -24,6 +24,7 @@
 #ifndef _mainloop_h
 #define _mainloop_h
 
+#include <stdint.h>
 #include "list.h"
 
 struct lxc_epoll_descr {
@@ -31,7 +32,7 @@ struct lxc_epoll_descr {
        struct lxc_list handlers;
 };
 
-typedef int (*lxc_mainloop_callback_t)(int fd, void *data,
+typedef int (*lxc_mainloop_callback_t)(int fd, uint32_t event, void *data,
                                       struct lxc_epoll_descr *descr);
 
 extern int lxc_mainloop(struct lxc_epoll_descr *descr, int timeout_ms);
index 2ffd7f2ea895fff6b477fe5d363241917efab9b0..0727c2ce79933eaa2f62b4821a361e2ac925c5b2 100644 (file)
@@ -237,7 +237,7 @@ static int setup_signal_fd(sigset_t *oldmask)
        return fd;
 }
 
-static int signal_handler(int fd, void *data,
+static int signal_handler(int fd, uint32_t events, void *data,
                           struct lxc_epoll_descr *descr)
 {
        struct signalfd_siginfo siginfo;