mirror of
https://github.com/samba-team/samba.git
synced 2025-01-11 05:18:09 +03:00
ctdb-scripts: Use ctdb_killtcp helper to kill connections
ctdb_killtcp will take up to 5 seconds to kill connections, so don't wait in a loop. Just check if there are remaining connections on completion and log a message either way. Also add a test stub. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
This commit is contained in:
parent
b417d79930
commit
83502a79dc
@ -464,13 +464,12 @@ kill_tcp_connections ()
|
|||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "$_connections" | ctdb killtcp || {
|
echo "$_connections" | \
|
||||||
echo "Failed to send killtcp control"
|
"${CTDB_HELPER_BINDIR}/ctdb_killtcp" "$_iface" || {
|
||||||
|
echo "Failed to kill TCP connections"
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
_count=0
|
|
||||||
while : ; do
|
|
||||||
_remaining=$(get_tcp_connections_for_ip $_ip | wc -l)
|
_remaining=$(get_tcp_connections_for_ip $_ip | wc -l)
|
||||||
|
|
||||||
if [ $_remaining -eq 0 ] ; then
|
if [ $_remaining -eq 0 ] ; then
|
||||||
@ -478,15 +477,8 @@ kill_tcp_connections ()
|
|||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
_count=$(($_count + 1))
|
_t="${_remaining}/${_killcount}"
|
||||||
if [ $_count -gt 3 ] ; then
|
echo "Failed to kill TCP connections for IP $_ip (${_t} remaining)"
|
||||||
echo "Timed out killing tcp connections for IP $_ip ($_remaining remaining)"
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "Waiting for $_remaining connections to be killed for IP $_ip"
|
|
||||||
sleep 1
|
|
||||||
done
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,10 +31,7 @@ while read dev ip bits ; do
|
|||||||
ok <<EOF
|
ok <<EOF
|
||||||
Killing TCP connection 10.254.254.1:43210 ${ip}:445
|
Killing TCP connection 10.254.254.1:43210 ${ip}:445
|
||||||
$out
|
$out
|
||||||
Waiting for 1 connections to be killed for IP ${ip}
|
Failed to kill TCP connections for IP 10.0.0.3 (1/11 remaining)
|
||||||
Waiting for 1 connections to be killed for IP ${ip}
|
|
||||||
Waiting for 1 connections to be killed for IP ${ip}
|
|
||||||
Timed out killing tcp connections for IP $ip (1 remaining)
|
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
simple_test $dev $ip $bits
|
simple_test $dev $ip $bits
|
||||||
|
9
ctdb/tests/eventscripts/stubs/ctdb_killtcp
Executable file
9
ctdb/tests/eventscripts/stubs/ctdb_killtcp
Executable file
@ -0,0 +1,9 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# Only supports reading from stdin
|
||||||
|
|
||||||
|
iface="$1" # ignored
|
||||||
|
|
||||||
|
while read src dst ; do
|
||||||
|
sed -i -e "/^${dst} ${src}\$/d" "$FAKE_NETSTAT_TCP_ESTABLISHED_FILE"
|
||||||
|
done
|
Loading…
Reference in New Issue
Block a user