]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
move the kill_tcp_connections() function from 10.interfaces to functions
authorRonnie Sahlberg <sahlberg@ronnie>
Wed, 10 Oct 2007 21:27:38 +0000 (07:27 +1000)
committerRonnie Sahlberg <sahlberg@ronnie>
Wed, 10 Oct 2007 21:27:38 +0000 (07:27 +1000)
(This used to be ctdb commit 055948530fb16bf49c42fc4489f29a21665156c0)

ctdb/config/events.d/10.interface
ctdb/config/functions

index 7d95a198373d9022bcc600b3fb57460c80307dd0..9fa4166ac0b65a9075aadb8ebc37631007a204a2 100755 (executable)
@@ -20,44 +20,6 @@ shift
        exit 0
 }
 
-################################################
-# kill off any TCP connections with the given IP
-kill_tcp_connections() {
-    _IP="$1"    
-    _failed=0
-
-    _killcount=0
-    connfile="$CTDB_BASE/state/connections.$_IP"
-    netstat -tn |egrep "^tcp.*\s+$_IP:.*ESTABLISHED" | awk '{print $4" "$5}' > $connfile
-    while read dest src; do
-       srcip=`echo $src | cut -d: -f1`
-       srcport=`echo $src | cut -d: -f2`
-       destip=`echo $dest | cut -d: -f1`
-       destport=`echo $dest | cut -d: -f2`
-       ctdb killtcp $srcip:$srcport $destip:$destport >/dev/null 2>&1 || _failed=1
-       echo "`date` Killing TCP connection $srcip:$srcport $destip:$destport"
-       _killcount=`expr $_killcount + 1`
-    done < $connfile
-    /bin/rm -f $connfile
-    [ $_failed = 0 ] || {
-       echo "`date` Failed to send killtcp control"
-       return;
-    }
-    [ $_killcount -gt 0 ] || {
-       return;
-    }
-    _count=0
-    while netstat -tn |egrep "^tcp.*\s+$_IP:.*ESTABLISHED" > /dev/null; do
-       sleep 1
-       _count=`expr $_count + 1`
-       [ $_count -gt 3 ] && {
-           echo "`date` Timed out killing tcp connections for IP $_IP"
-           return;
-       }
-    done
-    echo "`date` killed $_killcount TCP connections to released IP $_IP"
-}
-
 case $cmd in 
      #############################
      # called when ctdbd starts up
index 3c39addc02a56f9ad53b3db88068567b068752ca..d62a0bc07f344e3ab6366f241373d98a5ae26758 100644 (file)
@@ -183,3 +183,43 @@ ctdb_check_command() {
       exit 1
   }
 }
+
+################################################
+# kill off any TCP connections with the given IP
+################################################
+kill_tcp_connections() {
+    _IP="$1"    
+    _failed=0
+
+    _killcount=0
+    connfile="$CTDB_BASE/state/connections.$_IP"
+    netstat -tn |egrep "^tcp.*\s+$_IP:.*ESTABLISHED" | awk '{print $4" "$5}' > $connfile
+    while read dest src; do
+       srcip=`echo $src | cut -d: -f1`
+       srcport=`echo $src | cut -d: -f2`
+       destip=`echo $dest | cut -d: -f1`
+       destport=`echo $dest | cut -d: -f2`
+       ctdb killtcp $srcip:$srcport $destip:$destport >/dev/null 2>&1 || _failed=1
+       echo "`date` Killing TCP connection $srcip:$srcport $destip:$destport"
+       _killcount=`expr $_killcount + 1`
+    done < $connfile
+    /bin/rm -f $connfile
+    [ $_failed = 0 ] || {
+       echo "`date` Failed to send killtcp control"
+       return;
+    }
+    [ $_killcount -gt 0 ] || {
+       return;
+    }
+    _count=0
+    while netstat -tn |egrep "^tcp.*\s+$_IP:.*ESTABLISHED" > /dev/null; do
+       sleep 1
+       _count=`expr $_count + 1`
+       [ $_count -gt 3 ] && {
+           echo "`date` Timed out killing tcp connections for IP $_IP"
+           return;
+       }
+    done
+    echo "`date` killed $_killcount TCP connections to released IP $_IP"
+}
+