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) { 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) { if (errno == EBADF || errno == ENOENT) {
// already closed fd, do not die // already closed fd or not found, do not die
errno = 0; errno = 0;
} else { } else {
critical("Unable to remove file descriptor from epoll instance"); critical("Unable to remove file descriptor from epoll instance");
@@ -316,8 +316,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) { if (errno == EBADF || errno == ENOENT) {
// already closed fd, do not die // already closed fd or not found, do not die
errno = 0; errno = 0;
} else { } else {
critical("Unable to remove file descriptor from epoll instance"); 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(SIGINT, &act, NULL);
sigaction(SIGTERM, &act, NULL); sigaction(SIGTERM, &act, NULL);
debug("Closing listening sockets...");
for (int i = 0; i < NUM_SOCKETS; i++) { for (int i = 0; i < NUM_SOCKETS; i++) {
close(sockets[i]); close(sockets[i]);
} }
debug("Stopping workers...");
cache_stop(); cache_stop();
workers_stop(); workers_stop();
debug("Destroying workers...");
workers_destroy(); workers_destroy();
logger_set_prefix(""); logger_set_prefix("");
debug("Closing proxy connections...");
proxy_close_all(); proxy_close_all();
debug("Closing client connections...");
while (list_size(clients) > 0) while (list_size(clients) > 0)
tcp_close(clients[0]); tcp_close(clients[0]);
logger_set_prefix(""); logger_set_prefix("");
debug("Stopping async loop...");
async_stop(); async_stop();
} }