From d4d9dbb8e78db7d0f2f7e3d6e17da148e5b56d32 Mon Sep 17 00:00:00 2001 From: yrutschle Date: Tue, 9 Nov 2021 18:12:02 +0100 Subject: [PATCH] remove dependancy to watcher type in UDP timeout --- sslh-select.c | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/sslh-select.c b/sslh-select.c index 94b0582..3bcba86 100644 --- a/sslh-select.c +++ b/sslh-select.c @@ -126,23 +126,21 @@ static void udp_timeouts(struct loop_info* fd_info) time_t next_timeout = INT_MAX; - for (int i = 0; i < fd_info->watchers->max_fd; i++) { + for (int i = 0; i < watchers_maxfd(fd_info->watchers); i++) { /* if it's either in read or write set, there is a connection * behind that file descriptor */ - if (FD_ISSET(i, &fd_info->watchers->fds_r) || FD_ISSET(i, &fd_info->watchers->fds_w)) { - struct connection* cnx = collection_get_cnx_from_fd(fd_info->collection, i); - if (cnx) { - time_t timeout = udp_timeout(cnx); - if (!timeout) continue; /* Not a UDP connection */ - if (cnx && (timeout <= now)) { - print_message(msg_fd, "timed out UDP %d\n", cnx->target_sock); - close(cnx->target_sock); - watchers_del_read(fd_info->watchers, i); - watchers_del_write(fd_info->watchers, i); - collection_remove_cnx(fd_info->collection, cnx); - } else { - if (timeout < next_timeout) next_timeout = timeout; - } + struct connection* cnx = collection_get_cnx_from_fd(fd_info->collection, i); + if (cnx) { + time_t timeout = udp_timeout(cnx); + if (!timeout) continue; /* Not a UDP connection */ + if (cnx && (timeout <= now)) { + print_message(msg_fd, "timed out UDP %d\n", cnx->target_sock); + close(cnx->target_sock); + watchers_del_read(fd_info->watchers, i); + watchers_del_write(fd_info->watchers, i); + collection_remove_cnx(fd_info->collection, cnx); + } else { + if (timeout < next_timeout) next_timeout = timeout; } } }