From daba6cce095c3453c35a7471a023a3b5589f02ac Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Tue, 26 Jul 2022 07:47:09 +0200 Subject: [PATCH] Fix #5&: failure to reset socket count on SIGHUP As reported on GitHub. When logging to a remote host, after a few SIGHUP's we get the following log message: Only 16 IP addresses per socket supported. When closing all currently open sockets, the socket count must be reset to allow for opening new ones, otherwise we'll run out of "counts". Yes, this should be refactored to use the FreeBSD model implementation. Problem introduced in v2.4.0, commit 075815e. Signed-off-by: Joachim Wiberg --- src/syslogd.c | 1 + test/remote.sh | 13 +++++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/syslogd.c b/src/syslogd.c index bb48adf..6f40456 100644 --- a/src/syslogd.c +++ b/src/syslogd.c @@ -2645,6 +2645,7 @@ static void init(void) } else { for (size_t i = 0; i < pe->pe_socknum; i++) socket_close(pe->pe_sock[i]); + pe->pe_socknum = 0; if (SecureMode < 2) create_inet_socket(pe); diff --git a/test/remote.sh b/test/remote.sh index 735bd7c..8301bb0 100755 --- a/test/remote.sh +++ b/test/remote.sh @@ -1,6 +1,10 @@ #!/bin/sh # Verify that the sending to a remote IP:PORT works, note not receiving, # there's a test fwd.sh that verifies that. +# +# Also, instead of "sleep 3" after starting thsark, below, we take the +# opportunity to perform a regression test of SIGHUP:ing syslogd. +# # shellcheck disable=SC1090 set -x @@ -27,9 +31,14 @@ tshark -Qni lo -w "${CAP}" port 514 2>/dev/null & TPID="$!" echo "$TPID" >> "$DIR/PIDs" -# Wait for tshark to start up properly -sleep 3 +# While Waiting for tshark to start up properly we take the opportunity +# to verify syslogd survives a few SIGHUP's. The pe_sock[] has max 16 +# elements, which should get closed and refilled on SIGHUP. +for i in $(seq 1 20); do + reload +done +# Now send the message and see if we sent it ... logger ${MSG} # Wait for any OS delays, in particular on Travis