From 68b7b8e796d678557253d21d56cef35079dddd4d Mon Sep 17 00:00:00 2001 From: Darwvin Date: Mon, 12 Oct 2026 09:52:03 +0330 Subject: [PATCH] homer: reset TCP connection on EOF before sending HEP frames --- daemon/homer.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/daemon/homer.c b/daemon/homer.c index 703f2c9fa..3bcd58e22 100644 --- a/daemon/homer.c +++ b/daemon/homer.c @@ -93,8 +93,16 @@ static int __established(struct homer_sender *hs) { int ret; GString *gs; - // test connection with a dummy read + // Check for peer shutdown before writing another HEP frame. ret = read(hs->socket.fd, buf, sizeof(buf)); + if (ret == 0 && hs->protocol == SOCK_STREAM) { + // A TCP read of zero bytes means that the peer has closed the + // connection. Never reuse this socket for the next HEP frame. + ilog(LOG_NOTICE, "Homer TCP connection at %s closed by peer", + endpoint_print_buf(&hs->endpoint)); + __reset(hs); + return -1; + } if (ret < 0) { if (errno != EWOULDBLOCK && errno != EAGAIN) { ilog(LOG_ERR, "Connection error from Homer at %s: %s",