- fde = talloc(mem_ctx?mem_ctx:ev, struct tevent_fd);
- if (!fde) return NULL;
-
- fde->event_ctx = ev;
- fde->fd = fd;
- fde->flags = flags;
- fde->handler = handler;
- fde->private_data = private_data;
- fde->additional_flags = 0;
- fde->additional_data = NULL;
-
- DLIST_ADD(std_ev->fd_events, fde);
- if ((std_ev->maxfd != EVENT_INVALID_MAXFD)
- && (fde->fd > std_ev->maxfd)) {
- std_ev->maxfd = fde->fd;
- }
- talloc_set_destructor(fde, std_event_fd_destructor);
-
- epoll_add_event(std_ev, fde);
-
- return fde;
-}
-
-
-/*
- return the fd event flags
-*/
-static uint16_t std_event_get_fd_flags(struct tevent_fd *fde)
-{
- return fde->flags;
-}
-
-/*
- set the fd event flags
-*/
-static void std_event_set_fd_flags(struct tevent_fd *fde, uint16_t flags)
-{
- struct tevent_context *ev;
- struct std_event_context *std_ev;
-
- if (fde->flags == flags) return;
-
- ev = fde->event_ctx;
- std_ev = talloc_get_type(ev->additional_data, struct std_event_context);
-
- fde->flags = flags;
-
- epoll_check_reopen(std_ev);
-
- epoll_change_event(std_ev, fde);
-}
-
-/*
- event loop handling using select()
-*/
-static int std_event_loop_select(struct std_event_context *std_ev, struct timeval *tvalp)
-{
- fd_set r_fds, w_fds;
- struct tevent_fd *fde;
- int selrtn;
- uint32_t destruction_count = ++std_ev->destruction_count;
-
- /* we maybe need to recalculate the maxfd */
- if (std_ev->maxfd == EVENT_INVALID_MAXFD) {
- calc_maxfd(std_ev);
- }
-
- FD_ZERO(&r_fds);
- FD_ZERO(&w_fds);
-
- /* setup any fd events */
- for (fde = std_ev->fd_events; fde; fde = fde->next) {
- if (fde->flags & EVENT_FD_READ) {
- FD_SET(fde->fd, &r_fds);
- }
- if (fde->flags & EVENT_FD_WRITE) {
- FD_SET(fde->fd, &w_fds);