2 Commits

2 changed files with 10 additions and 4 deletions

View File

@@ -286,8 +286,8 @@ void async_thread(void) {
if (async_exec(evt, async_e2a(events[i].events)) == 0) {
logger_set_prefix("");
if (epoll_ctl(epoll_fd, EPOLL_CTL_DEL, evt->fd, NULL) == -1) {
if (errno == EBADF) {
// already closed fd, do not die
if (errno == EBADF || errno == ENOENT) {
// already closed fd or not found, do not die
errno = 0;
} else {
critical("Unable to remove file descriptor from epoll instance");
@@ -316,8 +316,8 @@ void async_thread(void) {
evt->to_cb(evt->arg);
if (epoll_ctl(epoll_fd, EPOLL_CTL_DEL, evt->fd, NULL) == -1) {
if (errno == EBADF) {
// already closed fd, do not die
if (errno == EBADF || errno == ENOENT) {
// already closed fd or not found, do not die
errno = 0;
} else {
critical("Unable to remove file descriptor from epoll instance");

View File

@@ -190,21 +190,27 @@ static void terminate_gracefully(int sig) {
sigaction(SIGINT, &act, NULL);
sigaction(SIGTERM, &act, NULL);
debug("Closing listening sockets...");
for (int i = 0; i < NUM_SOCKETS; i++) {
close(sockets[i]);
}
debug("Stopping workers...");
cache_stop();
workers_stop();
debug("Destroying workers...");
workers_destroy();
logger_set_prefix("");
debug("Closing proxy connections...");
proxy_close_all();
debug("Closing client connections...");
while (list_size(clients) > 0)
tcp_close(clients[0]);
logger_set_prefix("");
debug("Stopping async loop...");
async_stop();
}