static void dispatch_event(struct epoll_event *event) { Slot *slot = (Slot*) event->data.ptr; if (!slot->handler(slot->fd, event->events, slot->data)) { /* We are assuming here that the set of events returned by epoll doesn't * contain this file descriptor more than once. epoll(7) says that events * will be combined, so we should be safe. * * Note that closing the file descriptor automatically removes it from the * epoll set. */ close(slot->fd); free(slot); } }