* Ensure matched patterns match the begining of a line
* Log warnings when a line can't be parsed

Seems to resolve a problem where fallback servers aren't removed sometimes
due to the previously bogus parsing. Hoefully this parsing is less bogus.

Signed-off-by: Simon Horman <[EMAIL PROTECTED]>
Index: heartbeat/ldirectord/ldirectord.in
===================================================================
--- heartbeat.orig/ldirectord/ldirectord.in     2007-07-03 19:19:31.000000000 
+0900
+++ heartbeat/ldirectord/ldirectord.in  2007-07-03 19:19:35.000000000 +0900
@@ -1871,20 +1871,22 @@ sub ld_read_ipvsadm
                if (not defined $line) {
                        last;
                }
-               if ($line =~ 
/(\w+)\s+(\d+\.\d+\.\d+\.\d+\:\d+|\d+)\s+(\w+)\s+persistent\s+(\d+)\s+mask\s+(.*)/)
 {
+               if ($line =~ 
/^(\w+)\s+(\d+\.\d+\.\d+\.\d+\:\d+|\d+)\s+(\w+)\s+persistent\s+(\d+)\s+mask\s+(.*)/)
 {
                        $real_service = "$2 ".lc($1);
                        $oldsrv{"$real_service"} = {"real"=>{}, 
"scheduler"=>$3, "persistent"=>$4, "netmask"=>$5};
-               } elsif ($line =~ 
/(\w+)\s+(\d+\.\d+\.\d+\.\d+\:\d+|\d+)\s+(\w+)\s+persistent\s+(\d+)/) {
+               } elsif ($line =~ 
/^(\w+)\s+(\d+\.\d+\.\d+\.\d+\:\d+|\d+)\s+(\w+)\s+persistent\s+(\d+)/) {
                        $real_service = "$2 ".lc($1);
                        $oldsrv{"$real_service"} = {"real"=>{}, 
"scheduler"=>$3, "persistent"=>$4};
-               } elsif ($line =~ 
/(\w+)\s+(\d+\.\d+\.\d+\.\d+\:\d+|\d+)\s+(\w+)/) {
+               } elsif ($line =~ 
/^(\w+)\s+(\d+\.\d+\.\d+\.\d+\:\d+|\d+)\s+(\w+)/) {
                        $real_service = "$2 ".lc($1);
                        $oldsrv{"$real_service"} = {"real"=>{}, 
"scheduler"=>$3};
-               } else {
-                       next;
-               }
-               while ($line = ld_readline($fh, $buf)) {
-                       last unless $line =~ / 
->\s+(\d+\.\d+\.\d+\.\d+\:\d+)\s+(\w+)\s+(\d+)/;
+               } elsif ($line =~ /^  
->\s+(\d+\.\d+\.\d+\.\d+\:\d+)\s+(\w+)\s+(\d+)/) {
+                       if (not defined( $real_service)) {
+                               &ld_debug(2, "Real server read from ipvsadm " .
+                                         "doesn't seem to be inside a " .
+                                         "virtual service: \"$line\"\n");
+                               next;
+                       }
                        if ($2 eq "Route") {
                                $fwd = "gate";
                        } elsif ($2 eq "Tunnel") {
@@ -1893,8 +1895,11 @@ sub ld_read_ipvsadm
                                $fwd = "masq";
                        }
                        $oldsrv{"$real_service"}->{"real"}->{"$1"} = 
{"forward"=>$fwd, "weight"=>$3};
+               } else {
+                       &ld_debug(2, "Unknown line read from ipvsadm: " .
+                                 "\"$line\"\n");
+                       next;
                }
-               redo;
        }
        close($fh);
 

-- 

-- 
Horms
  H: http://www.vergenet.net/~horms/
  W: http://www.valinux.co.jp/en/

_______________________________________________________
Linux-HA-Dev: [email protected]
http://lists.linux-ha.org/mailman/listinfo/linux-ha-dev
Home Page: http://linux-ha.org/

Reply via email to