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 <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg 2022-07-26 07:47:09 +02:00
parent e41721216c
commit daba6cce09
2 changed files with 12 additions and 2 deletions

View File

@ -2645,6 +2645,7 @@ static void init(void)
} else { } else {
for (size_t i = 0; i < pe->pe_socknum; i++) for (size_t i = 0; i < pe->pe_socknum; i++)
socket_close(pe->pe_sock[i]); socket_close(pe->pe_sock[i]);
pe->pe_socknum = 0;
if (SecureMode < 2) if (SecureMode < 2)
create_inet_socket(pe); create_inet_socket(pe);

View File

@ -1,6 +1,10 @@
#!/bin/sh #!/bin/sh
# Verify that the sending to a remote IP:PORT works, note not receiving, # Verify that the sending to a remote IP:PORT works, note not receiving,
# there's a test fwd.sh that verifies that. # 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 # shellcheck disable=SC1090
set -x set -x
@ -27,9 +31,14 @@ tshark -Qni lo -w "${CAP}" port 514 2>/dev/null &
TPID="$!" TPID="$!"
echo "$TPID" >> "$DIR/PIDs" echo "$TPID" >> "$DIR/PIDs"
# Wait for tshark to start up properly # While Waiting for tshark to start up properly we take the opportunity
sleep 3 # 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} logger ${MSG}
# Wait for any OS delays, in particular on Travis # Wait for any OS delays, in particular on Travis