diff options
author | Marcin Siodelski <marcin@isc.org> | 2016-05-17 18:17:55 +0200 |
---|---|---|
committer | Marcin Siodelski <marcin@isc.org> | 2016-05-17 18:17:55 +0200 |
commit | 4ea1ed0cab608ed8236cef777ba80a4a0504c378 (patch) | |
tree | ff70f101dea56f2b76209b4868433c880e6c904c /src/lib/dhcpsrv/cfg_hosts.cc | |
parent | [master] Added ChangeLog entry 1115 for #4481 (diff) | |
download | kea-4ea1ed0cab608ed8236cef777ba80a4a0504c378.tar.xz kea-4ea1ed0cab608ed8236cef777ba80a4a0504c378.zip |
[4499] Removed inefficient conversion of the host identifier to text.
Diffstat (limited to 'src/lib/dhcpsrv/cfg_hosts.cc')
-rw-r--r-- | src/lib/dhcpsrv/cfg_hosts.cc | 28 |
1 files changed, 5 insertions, 23 deletions
diff --git a/src/lib/dhcpsrv/cfg_hosts.cc b/src/lib/dhcpsrv/cfg_hosts.cc index 7d37d2bdfa..2f4a0d1785 100644 --- a/src/lib/dhcpsrv/cfg_hosts.cc +++ b/src/lib/dhcpsrv/cfg_hosts.cc @@ -98,33 +98,15 @@ CfgHosts::getAllInternal(const Host::IdentifierType& identifier_type, const uint8_t* identifier, const size_t identifier_len, Storage& storage) const { - // We will need to transform the identifier into the textual format. - // Until we do it, we mark it as invalid. - std::string identifier_text = "(invalid)"; - try { - // Use Host object to find the textual form of the identifier. - // This may throw exception if the identifier is invalid. - Host host(identifier, identifier_len, identifier_type, - SubnetID(0), SubnetID(0), IOAddress::IPV4_ZERO_ADDRESS()); - identifier_text = host.getIdentifierAsText(); - - } catch (...) { - // Suppress exception and keep using (invalid) as an - // identifier. We will log that the identifier is - // invalid and return. - } - // This will log that we're invoking this function with the specified - // identifier. The identifier may also be marked as (invalid) if it - // had 0 length or its type is unsupported. + // Convert host identifier into textual format for logging purposes. + // This conversion is exception free. + std::string identifier_text = Host::getIdentifierAsText(identifier_type, + identifier, + identifier_len); LOG_DEBUG(hosts_logger, HOSTS_DBG_TRACE, HOSTS_CFG_GET_ALL_IDENTIFIER) .arg(identifier_text); - // Do nothing if the identifier specified is invalid. - if (identifier_text == "(invalid)") { - return; - } - // Use the identifier and identifier type as a composite key. const HostContainerIndex0& idx = hosts_.get<0>(); boost::tuple<const std::vector<uint8_t>, const Host::IdentifierType> t = |