ctdb-scripts: Optimise tickle_tcp_connections()
authorMartin Schwenke <martin@meltin.net>
Tue, 8 Sep 2015 01:29:25 +0000 (11:29 +1000)
committerAmitay Isaacs <amitay@samba.org>
Thu, 8 Sep 2016 08:45:42 +0000 (10:45 +0200)
Pipe the connections to "ctdb tickle" on stdin to avoid having to fork
so many "ctdb tickle" processes.  This maintains the current level of
verbosity at the price of some extra memory usage.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
Autobuild-User(master): Amitay Isaacs <amitay@samba.org>
Autobuild-Date(master): Thu Sep  8 10:45:42 CEST 2016 on sn-devel-144

ctdb/config/functions

index d5443f5767abd2f0e743d23a90c066e62df7d2dc..ac9aa917ae1f6b8fc24d52c73ba50b1adf4bbc5c 100755 (executable)
@@ -520,21 +520,12 @@ tickle_tcp_connections ()
 {
     _ip="$1"
 
-    get_tcp_connections_for_ip "$_ip" |
-    {
-       _failed=false
-
-       while read dest src; do
-           echo "Tickle TCP connection $src $dest"
-           $CTDB tickle "$src" "$dest" >/dev/null 2>&1 || _failed=true
-           echo "Tickle TCP connection $dest $src"
-           $CTDB tickle "$dest" "$src" >/dev/null 2>&1 || _failed=true
-       done
+    # Get connections, both directions
+    _conns=$(get_tcp_connections_for_ip "$_ip" | \
+                   awk '{ print $1, $2 ; print $2, $1 }')
 
-       if $_failed ; then
-           echo "Failed to send tickle control"
-       fi
-    }
+    echo "$_conns" | awk '{ print "Tickle TCP connection", $1, $2 }'
+    echo "$_conns" | ctdb tickle
 }
 
 get_tcp_connections_for_ip ()