Commit 84c92abd by Dwight Engen Committed by Stéphane Graber

add epoll events to mainloop callback handlers

Adding the epoll events allows the handler to determine what events happened on the fd. Signed-off-by: 's avatarDwight Engen <dwight.engen@oracle.com> Acked-by: 's avatarStéphane Graber <stgraber@ubuntu.com>
parent 341c9718
......@@ -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;
......
......@@ -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;
......
......@@ -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;
......
......@@ -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;
......
......@@ -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;
}
......
......@@ -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);
......
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment