- struct pollfd *p = m->poll_table;
- CLIST_FOR_EACH(struct main_file *, fi, m->file_list)
+ struct epoll_event *e = &m->epoll_events[i];
+ struct main_file *fi = e->data.ptr;
+ clist_remove(&fi->n);
+ clist_add_tail(&m->file_active_list, &fi->n);
+ fi->events = e->events;
+ }
+#else
+ struct pollfd *p = m->poll_table;
+ struct main_file **pf = m->poll_file_table;
+ for (uns i=0; i < m->file_cnt; i++)
+ if (p[i].revents)
+ {
+ struct main_file *fi = pf[i];
+ clist_remove(&fi->n);
+ clist_add_tail(&m->file_active_list, &fi->n);
+ fi->events = p[i].revents;
+ }
+#endif
+
+ // Process the buffered file events
+ struct main_file *fi;
+ while (fi = clist_remove_head(&m->file_active_list))
+ {
+ clist_add_tail(&m->file_list, &fi->n);
+ if (fi->events & (POLLIN | POLLHUP | POLLERR))
+ {
+ do
+ DBG("MAIN: Read event on fd %d", fi->fd);
+ while (fi->read_handler && fi->read_handler(fi));
+ }
+ if (fi->events & (POLLOUT | POLLERR))