From 02573eb44bb70e4289954d9b1ec2bf9479f41699 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yves=20R=C5=B1tschl=C3=A9?= Date: Thu, 3 Nov 2022 17:23:49 +0100 Subject: [PATCH] only process write events if file descriptor has not been tidied (may fix #355) --- sslh-select.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sslh-select.c b/sslh-select.c index bf75ce6..50cc6d3 100644 --- a/sslh-select.c +++ b/sslh-select.c @@ -168,7 +168,10 @@ void main_loop(struct listen_endpoint listen_sockets[], int num_addr_listen) /* Check all sockets for write activity */ for (i = 0; i < fd_info.watchers->max_fd; i++) { - if (FD_ISSET(i, &writefds)) { + /* Check if it's active AND currently monitored (if a connection + * died, it gets tidied, which closes both sockets, but writefs does + * not know about that */ + if (FD_ISSET(i, &writefds) && FD_ISSET(i, &fd_info.watchers->fds_w)) { cnx_write_process(&fd_info, i); } }