From: Joe Atzberger Date: Thu, 7 Oct 2010 19:40:38 +0000 (+0000) Subject: Die if no listeners in config, give better log messages X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=07fac40fbc9a53e57979dd550f5dd39aefa43b58;p=SIPServer.git Die if no listeners in config, give better log messages Also tighten debug messages: one warning at the end listing all failed is good enough. Certainly better than just throwaway debug messages listing what we are going to try. Otherwise if we succeeded, we don't need to know about the ones that failed, just report the successful one. --- diff --git a/Sip/Configuration.pm b/Sip/Configuration.pm index e15f895..4f36f1a 100644 --- a/Sip/Configuration.pm +++ b/Sip/Configuration.pm @@ -100,15 +100,19 @@ sub accounts { sub find_service { my ( $self, $sockaddr, $port, $proto ) = @_; my $portstr; - - $proto = lc($proto); - foreach my $addr ('', '*:', "$sockaddr:") { - $portstr = sprintf("%s%s/%s", $addr, $port, lc $proto); - Sys::Syslog::syslog("LOG_DEBUG", "Configuration::find_service: Trying $portstr"); - last if (exists(($self->{listeners})->{$portstr})); + $self->{listeners} or die "ERROR: " . __PACKAGE__ . " object has no {listeners} for find_service() to find!"; + + my @misses; + foreach my $addr ( '', '*:', "$sockaddr:" ) { + $portstr = sprintf( "%s%s/%s", $addr, $port, lc $proto ); + if (exists($self->{listeners}->{$portstr})) { + Sys::Syslog::syslog("LOG_DEBUG", "find_service: Matched $portstr" ); + return $self->{listeners}->{$portstr}; + } + push @misses, $portstr; } - - return $self->{listeners}->{$portstr}; + Sys::Syslog::syslog("LOG_WARN", "find_service: No match in: " . join(' ',@misses)); + return; } 1;