Handle EBADF in async

This commit is contained in:
2023-07-08 13:38:19 +02:00
parent beec199192
commit 37671546ef

View File

@ -245,9 +245,19 @@ void async_thread(void) {
while (epoll_ctl(epoll_fd, EPOLL_CTL_ADD, evt->fd, &ev) == -1) { while (epoll_ctl(epoll_fd, EPOLL_CTL_ADD, evt->fd, &ev) == -1) {
if (errno == EEXIST) { if (errno == EEXIST) {
// fd already exists, delete old one
errno = 0; errno = 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)
continue; continue;
} else if (errno == EBADF) {
// fd probably already closed
errno = 0;
local = list_delete(local, &evt);
if (local == NULL) {
critical("Unable to resize async local list");
return;
}
break;
} }
critical("Unable to add file descriptor to epoll instance"); critical("Unable to add file descriptor to epoll instance");
return; return;