From e0ee25628febdcecbb93356934286d7bd273023f Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Wed, 29 May 2013 19:54:09 +0100 Subject: [PATCH] avoid unecessary log for queueing --- Netdisco/lib/App/Netdisco/Core/Discover.pm | 24 +++++++++++++--------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/Netdisco/lib/App/Netdisco/Core/Discover.pm b/Netdisco/lib/App/Netdisco/Core/Discover.pm index 742aa8ae..f977b417 100644 --- a/Netdisco/lib/App/Netdisco/Core/Discover.pm +++ b/Netdisco/lib/App/Netdisco/Core/Discover.pm @@ -119,7 +119,7 @@ sub _set_canonical_ip { my $oldip = $device->ip; my $newip = $snmp->root_ip; - if (length $newip) { + if (defined $newip) { if ($oldip ne $newip) { debug sprintf ' [%s] device - changing root IP to alt IP %s', $oldip, $newip; @@ -666,11 +666,13 @@ sub store_neighbors { ' [%s] neigh - port %s has multiple neighbors, setting remote as self', $device->ip, $port; - foreach my $n (@$remote_ip) { - debug sprintf - ' [%s] neigh - adding neighbor %s, type [%s], on %s to discovery queue', - $device->ip, $n, $remote_type, $port; - push @to_discover, [$n, $remote_type]; + if (wantarray) { + foreach my $n (@$remote_ip) { + debug sprintf + ' [%s] neigh - adding neighbor %s, type [%s], on %s to discovery queue', + $device->ip, $n, $remote_type, $port; + push @to_discover, [$n, $remote_type]; + } } # set self as remote IP to suppress any further work @@ -679,10 +681,12 @@ sub store_neighbors { } else { # what we came here to do.... discover the neighbor - debug sprintf - ' [%s] neigh - adding neighbor %s, type [%s], on %s to discovery queue', - $device->ip, $remote_ip, $remote_type, $port; - push @to_discover, [$remote_ip, $remote_type]; + if (wantarray) { + debug sprintf + ' [%s] neigh - adding neighbor %s, type [%s], on %s to discovery queue', + $device->ip, $remote_ip, $remote_type, $port; + push @to_discover, [$remote_ip, $remote_type]; + } $remote_port = $c_port->{$entry};