Catch EBADF in async

This commit is contained in:
2023-01-05 22:04:18 +01:00
parent 4782707049
commit c7be0adc66

View File

@ -256,8 +256,13 @@ void async_thread(void) {
evt_listen_t *evt = events[i].data.ptr; evt_listen_t *evt = events[i].data.ptr;
if (async_exec(evt, async_e2a(events[i].events)) == 0) { if (async_exec(evt, async_e2a(events[i].events)) == 0) {
if (epoll_ctl(epoll_fd, EPOLL_CTL_DEL, evt->fd, NULL) == -1) { if (epoll_ctl(epoll_fd, EPOLL_CTL_DEL, evt->fd, NULL) == -1) {
critical("Unable to remove file descriptor from epoll instance"); if (errno == EBADF) {
return; // already closed fd, do not die
errno = 0;
} else {
critical("Unable to remove file descriptor from epoll instance");
return;
}
} }
local = list_delete(local, &evt); local = list_delete(local, &evt);