From: Martin Schwenke Date: Fri, 11 Mar 2016 04:30:47 +0000 (+1100) Subject: ctdb-scripts: Use ctdb_killtcp helper to kill connections X-Git-Tag: tdb-1.3.9~44 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=83502a79dc3d7907525be01438d0e28dad7285bd;p=thirdparty%2Fsamba.git 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 Reviewed-by: Amitay Isaacs --- diff --git a/ctdb/config/functions b/ctdb/config/functions index aab7a143529..7c28e4ce04b 100755 --- a/ctdb/config/functions +++ b/ctdb/config/functions @@ -464,29 +464,21 @@ kill_tcp_connections () return fi - echo "$_connections" | ctdb killtcp || { - echo "Failed to send killtcp control" - return + echo "$_connections" | \ + "${CTDB_HELPER_BINDIR}/ctdb_killtcp" "$_iface" || { + echo "Failed to kill TCP connections" + 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 echo "Killed $_killcount TCP connections to released IP $_ip" return - fi - - _count=$(($_count + 1)) - if [ $_count -gt 3 ] ; then - echo "Timed out killing tcp connections for IP $_ip ($_remaining remaining)" - return - fi + fi - echo "Waiting for $_remaining connections to be killed for IP $_ip" - sleep 1 - done + _t="${_remaining}/${_killcount}" + echo "Failed to kill TCP connections for IP $_ip (${_t} remaining)" } } diff --git a/ctdb/tests/eventscripts/10.interface.releaseip.011.sh b/ctdb/tests/eventscripts/10.interface.releaseip.011.sh index e1514eea880..6203b97e2f5 100755 --- a/ctdb/tests/eventscripts/10.interface.releaseip.011.sh +++ b/ctdb/tests/eventscripts/10.interface.releaseip.011.sh @@ -31,10 +31,7 @@ while read dev ip bits ; do ok <