Try to solve epoll critical errors
This commit is contained in:
18
src/async.c
18
src/async.c
@@ -6,7 +6,6 @@
|
|||||||
* @date 2022-12-28
|
* @date 2022-12-28
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "async.h"
|
|
||||||
#include "logger.h"
|
#include "logger.h"
|
||||||
#include "lib/list.h"
|
#include "lib/list.h"
|
||||||
#include "lib/utils.h"
|
#include "lib/utils.h"
|
||||||
@@ -21,6 +20,8 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <openssl/ssl.h>
|
#include <openssl/ssl.h>
|
||||||
|
|
||||||
|
#include "async.h"
|
||||||
|
|
||||||
#define ASYNC_MAX_EVENTS 16
|
#define ASYNC_MAX_EVENTS 16
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@@ -298,8 +299,9 @@ void async_thread(void) {
|
|||||||
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) {
|
} else if (errno == EBADF || errno == EPERM) {
|
||||||
// fd probably already closed
|
// fd probably already closed or does not support epoll somehow
|
||||||
|
// FIXME should not happen
|
||||||
warning("Unable to add file descriptor to epoll instance");
|
warning("Unable to add file descriptor to epoll instance");
|
||||||
errno = 0;
|
errno = 0;
|
||||||
local = list_delete(local, &evt);
|
local = list_delete(local, &evt);
|
||||||
@@ -347,9 +349,8 @@ void async_thread(void) {
|
|||||||
if (async_exec(evt, async_e2a(events[i].events)) == 0) {
|
if (async_exec(evt, async_e2a(events[i].events)) == 0) {
|
||||||
logger_set_prefix("");
|
logger_set_prefix("");
|
||||||
if (epoll_ctl(epoll_fd, EPOLL_CTL_DEL, evt->fd, NULL) == -1) {
|
if (epoll_ctl(epoll_fd, EPOLL_CTL_DEL, evt->fd, NULL) == -1) {
|
||||||
if (errno == EBADF || errno == ENOENT) {
|
if (errno == EBADF || errno == ENOENT || errno == EPERM) {
|
||||||
// already closed fd or not found, do not die
|
// already closed, fd not found, or fd does not support epoll, anyway do not die
|
||||||
warning("Unable to remove file descriptor from epoll instance");
|
|
||||||
errno = 0;
|
errno = 0;
|
||||||
} else {
|
} else {
|
||||||
critical("Unable to remove file descriptor from epoll instance");
|
critical("Unable to remove file descriptor from epoll instance");
|
||||||
@@ -378,9 +379,8 @@ void async_thread(void) {
|
|||||||
evt->to_cb(evt->arg);
|
evt->to_cb(evt->arg);
|
||||||
|
|
||||||
if (epoll_ctl(epoll_fd, EPOLL_CTL_DEL, evt->fd, NULL) == -1) {
|
if (epoll_ctl(epoll_fd, EPOLL_CTL_DEL, evt->fd, NULL) == -1) {
|
||||||
if (errno == EBADF || errno == ENOENT) {
|
if (errno == EBADF || errno == ENOENT || errno == EPERM) {
|
||||||
// already closed fd or not found, do not die
|
// already closed, fd not found, or fd does not support epoll, anyway do not die
|
||||||
warning("Unable to remove file descriptor from epoll instance");
|
|
||||||
errno = 0;
|
errno = 0;
|
||||||
} else {
|
} else {
|
||||||
critical("Unable to remove file descriptor from epoll instance");
|
critical("Unable to remove file descriptor from epoll instance");
|
||||||
|
Reference in New Issue
Block a user