t_server_null: use wait instead of marker files

By using wait in a more inventive way we can avoid using a marker file
to detect the "server could not be killed gracefully" situation.

Change-Id: Ib385080e1dd1c3046c54e6267db8aa7d5c09e2fb
Signed-off-by: Samuli Seppänen <samuli.seppanen@gmail.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20241026092515.30559-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg29664.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
This commit is contained in:
Samuli Seppänen 2024-10-26 11:25:14 +02:00 committed by Gert Doering
parent 37db7fe37a
commit 5dd1b8b063
2 changed files with 10 additions and 8 deletions

View File

@ -62,6 +62,8 @@ export t_server_null_logdir=t_server_null-`hostname`-`date +%Y%m%d-%H%M%S`
mkdir $t_server_null_logdir mkdir $t_server_null_logdir
"${srcdir}/t_server_null_server.sh" & "${srcdir}/t_server_null_server.sh" &
T_SERVER_NULL_SERVER_PID=$!
"${srcdir}/t_server_null_client.sh" "${srcdir}/t_server_null_client.sh"
retval=$? retval=$?
@ -69,11 +71,9 @@ retval=$?
# that this script does not exit before all --dev null servers are dead and # that this script does not exit before all --dev null servers are dead and
# their network interfaces are gone. Otherwise t_client.sh will fail because # their network interfaces are gone. Otherwise t_client.sh will fail because
# pre and post ifconfig output does not match. # pre and post ifconfig output does not match.
wait wait $T_SERVER_NULL_SERVER_PID
. ./t_server_null_default.rc if [ $? -ne 0 ]; then
if [ -e $SERVER_KILL_FAIL_FILE ]; then
exit 1 exit 1
else else
exit $retval exit $retval

View File

@ -37,8 +37,9 @@ umask 022
# Load local configuration, if any # Load local configuration, if any
test -r ./t_server_null.rc && . ./t_server_null.rc test -r ./t_server_null.rc && . ./t_server_null.rc
# Remove server kill failure marker file, if any # We can't exit immediately on the first failure as that could leave processes
rm -f $SERVER_KILL_FAIL_FILE # lying around.
retval=0
# Launch test servers # Launch test servers
for SUF in $TEST_SERVER_LIST for SUF in $TEST_SERVER_LIST
@ -81,7 +82,6 @@ echo "All clients have disconnected from all servers"
# Make sure that the server processes are truly dead before exiting. If a # Make sure that the server processes are truly dead before exiting. If a
# server process does not exit in 15 seconds assume it never will, move on and # server process does not exit in 15 seconds assume it never will, move on and
# hope for the best. # hope for the best.
echo "Waiting for servers to exit" echo "Waiting for servers to exit"
for PID_FILE in $server_pid_files for PID_FILE in $server_pid_files
do do
@ -111,6 +111,8 @@ do
echo "ERROR: had to send SIGKILL to server ${SERVER_NAME} with pid ${SERVER_PID}!" echo "ERROR: had to send SIGKILL to server ${SERVER_NAME} with pid ${SERVER_PID}!"
echo "Tail of server log:" echo "Tail of server log:"
tail -n 20 "${t_server_null_logdir}/${SERVER_NAME}.log" tail -n 20 "${t_server_null_logdir}/${SERVER_NAME}.log"
touch $SERVER_KILL_FAIL_FILE retval=1
fi fi
done done
exit $retval