Commit 8dbdf24f authored by Matthieu Baerts's avatar Matthieu Baerts Committed by Paolo Abeni
Browse files

selftests: mptcp: userspace: avoid read errors



During the cleanup phase, the server pids were killed with a SIGTERM
directly, not using a SIGUSR1 first to quit safely. As a result, this
test was often ending with two error messages:

  read: Connection reset by peer

While at it, use a for-loop to terminate all the PIDs the same way.

Also the different files are now removed after having killed the PIDs
using them. It makes more sense to do that in this order.

Reviewed-by: default avatarMat Martineau <mathew.j.martineau@linux.intel.com>
Signed-off-by: default avatarMatthieu Baerts <matthieu.baerts@tessares.net>
Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
parent 10d42734
Loading
Loading
Loading
Loading
+12 −20
Original line number Original line Diff line number Diff line
@@ -50,6 +50,9 @@ print_title()


kill_wait()
kill_wait()
{
{
	[ $1 -eq 0 ] && return 0

	kill -SIGUSR1 $1 > /dev/null 2>&1
	kill $1 > /dev/null 2>&1
	kill $1 > /dev/null 2>&1
	wait $1 2>/dev/null
	wait $1 2>/dev/null
}
}
@@ -58,32 +61,21 @@ cleanup()
{
{
	print_title "Cleanup"
	print_title "Cleanup"


	rm -rf $file $client_evts $server_evts

	# Terminate the MPTCP connection and related processes
	# Terminate the MPTCP connection and related processes
	if [ $client4_pid -ne 0 ]; then
	local pid
		kill -SIGUSR1 $client4_pid > /dev/null 2>&1
	for pid in $client4_pid $server4_pid $client6_pid $server6_pid\
	fi
		   $server_evts_pid $client_evts_pid
	if [ $server4_pid -ne 0 ]; then
	do
		kill_wait $server4_pid
		kill_wait $pid
	fi
	done
	if [ $client6_pid -ne 0 ]; then

		kill -SIGUSR1 $client6_pid > /dev/null 2>&1
	fi
	if [ $server6_pid -ne 0 ]; then
		kill_wait $server6_pid
	fi
	if [ $server_evts_pid -ne 0 ]; then
		kill_wait $server_evts_pid
	fi
	if [ $client_evts_pid -ne 0 ]; then
		kill_wait $client_evts_pid
	fi
	local netns
	local netns
	for netns in "$ns1" "$ns2" ;do
	for netns in "$ns1" "$ns2" ;do
		ip netns del "$netns"
		ip netns del "$netns"
	done
	done


	rm -rf $file $client_evts $server_evts

	stdbuf -o0 -e0 printf "Done\n"
	stdbuf -o0 -e0 printf "Done\n"
}
}