From 83502a79dc3d7907525be01438d0e28dad7285bd Mon Sep 17 00:00:00 2001 From: Martin Schwenke Date: Fri, 11 Mar 2016 15:30:47 +1100 Subject: [PATCH] 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 --- ctdb/config/functions | 26 +++++++------------ .../10.interface.releaseip.011.sh | 5 +--- ctdb/tests/eventscripts/stubs/ctdb_killtcp | 9 +++++++ 3 files changed, 19 insertions(+), 21 deletions(-) create mode 100755 ctdb/tests/eventscripts/stubs/ctdb_killtcp 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 + fi - _count=$(($_count + 1)) - if [ $_count -gt 3 ] ; then - 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 + _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 <