diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2019-08-20 18:29:33 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2019-08-20 18:29:33 +0300 |
commit | 9aa788734ab432ef374e88cf550cb8577bdfbfc2 (patch) | |
tree | e9eab8bce1cf9482415ad2a3cf445c014f872311 | |
parent | 64c398c8dd1bf734fdc9cc8e9638cd039d353b89 (diff) | |
download | dnstools-9aa788734ab432ef374e88cf550cb8577bdfbfc2.tar.gz dnstools-9aa788734ab432ef374e88cf550cb8577bdfbfc2.tar.bz2 |
Fix silly bugs in dgd
-rwxr-xr-x | dgd/dgd | 31 |
1 files changed, 19 insertions, 12 deletions
@@ -187,4 +187,4 @@ sub check_mandatory { if (ref($d) eq 'HASH' - and $d->{mandatory} - and !exists($section->{$k})) { + && $d->{mandatory} + && !exists($section->{$k})) { if (exists($d->{section})) { @@ -249,3 +249,3 @@ sub readconfig { if (ref($param{kw}{$rootname}) eq 'HASH' - and exists($param{kw}{$rootname}{section})) { + && exists($param{kw}{$rootname}{section})) { $kw = $param{kw}{$rootname}{section}; @@ -295,3 +295,3 @@ sub readconfig { if (exists($x->{check}) - and !&{$x->{check}}($v, "$file:$line")) { + && !&{$x->{check}}($v, "$file:$line")) { ++$err; @@ -304,3 +304,3 @@ sub readconfig { } - } elsif (!exists($x->{var}) and !exists($x->{mandatory})) { + } elsif (!exists($x->{var}) && !exists($x->{mandatory})) { error("$file:$line: unknown keyword $k"); @@ -320,3 +320,3 @@ sub readconfig { close $fd; - # if (defined($param{kw}) and !$param{include}) { + # if (defined($param{kw}) && !$param{include}) { # $err += check_mandatory($conf, $param{kw}, "$file:$line", 1); @@ -436,5 +436,6 @@ sub check_links { foreach $link (@links) { + $link->{prevstate} = link_is_alive($link); $link->{alive} = 0; } - debug(1, "checking links ".($#links+1).", probes $config{core}{probes}"); + debug(2, "checking links ".($#links+1).", probes $config{core}{probes}"); for (my $i = 0; $i < $config{core}{probes}; $i++) { @@ -442,3 +443,3 @@ sub check_links { next if link_is_alive($link); - debug(3, "ping $link->{name}"); + debug(3, "ping $link->{name} $link->{gw} $link->{if}"); my $p = Net::Ping->new("icmp", $config{core}{timeout}, undef, @@ -446,4 +447,10 @@ sub check_links { ++$link->{alive} if $p->ping($link->{gw}); - $p->close(); - debug(3, "$link->{name} " . ($link->{alive} ? "alive" : "dead")); + } + } + if ($debug) { + foreach $link (@links) { + if ($link->{prevstate} != link_is_alive($link)) { + debug(1, "$link->{name} state changed to " . (link_is_alive($link) ? "alive" : "dead")); + } +# print "Link $link->{name} is ".(link_is_alive($link)?"up":"down")."\n"; } @@ -577,3 +584,3 @@ $SIG{HUP} = sub { -$use_syslog = defined $config{syslog}{facility}; +$use_syslog = defined $config{syslog}{facility} && !$foreground; @@ -585,3 +592,3 @@ while (1) { if (link_is_alive($i) - and $links[$i]->{priority} < $links[$active_link]->{priority}) { + && $links[$i]->{priority} < $links[$active_link]->{priority}) { diag('info', "switching to higher priority link $links[$i]->{name}"); |