split evt loop

This commit is contained in:
Quentin 2020-02-05 23:21:27 +01:00
parent c5d48ecd37
commit 077d357f56

View file

@ -272,9 +272,10 @@ void evt_core_loop(struct evt_core_ctx* ctx) {
continue;
}
for (n = 0 ; n < num_fd; n++) {
// 1. Handle errors
if (events[n].events & (EPOLLERR | EPOLLHUP | EPOLLRDHUP)) {
for (n = 0 ; n < num_fd; n++) {
if (!(events[n].events & (EPOLLERR | EPOLLHUP | EPOLLRDHUP))) continue;
int err_fd = events[n].data.fd;
int evt = events[n].events;
if (evt & EPOLLRDHUP) fprintf(stderr, "Epoll Read Hup Event fd=%d.\n", err_fd);
@ -313,10 +314,11 @@ void evt_core_loop(struct evt_core_ctx* ctx) {
fprintf(stderr, "The file descriptor %d is not registered in a category, this is probably a logic error\n", err_fd);
close (err_fd);
}
continue;
}
// 2. Fetch info and call appropriate function
for (n = 0 ; n < num_fd; n++) {
if (events[n].events & (EPOLLERR | EPOLLHUP | EPOLLRDHUP)) continue;
fdinfo = g_hash_table_lookup(ctx->socklist, &(events[n].data.fd));
if (fdinfo == NULL) {
fprintf(stderr, "Ignoring file descriptor %d as it is not registered. This is a bug.\n", events[n].data.fd);