From: Stephen Morris Date: Mon, 15 Dec 2014 14:45:28 +0000 (+0000) Subject: [3643] Fix problem on Ubuntu and NetBSD Builds X-Git-Tag: kea-eng-20141219~3 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=32f06c29c0ab3ce02455c04f23034951162d265f;p=thirdparty%2Fkea.git [3643] Fix problem on Ubuntu and NetBSD Builds Both Ubuntu and NetBSD builds fail because of what appears to be an error trying to the use "equal_range" method of one of the classes associated with the Boost multi-index container. The cause is uncertain - other systems build successfully, so the problem might no lie here, e.g. it could be in the compiler. This fix attempts to side-step the problem by modifying the affected files so as not to use this method. --- diff --git a/src/lib/dhcpsrv/cfg_hosts.cc b/src/lib/dhcpsrv/cfg_hosts.cc index 8bb17f3cc3..4b7936815d 100644 --- a/src/lib/dhcpsrv/cfg_hosts.cc +++ b/src/lib/dhcpsrv/cfg_hosts.cc @@ -50,13 +50,13 @@ void CfgHosts::getAllInternal(const std::vector& identifier, const Host::IdentifierType& identifier_type, Storage& storage) const { - // Search for the Host using the identifier and identifier type as a - // composite key. + // Use the identifier and identifier type as a composite key. const HostContainerIndex0& idx = hosts_.get<0>(); - std::pair r = - idx.equal_range(boost::make_tuple(identifier, identifier_type)); + boost::tuple, const Host::IdentifierType> t = + boost::make_tuple(identifier, identifier_type); + // Append each Host object to the storage. - for (HostContainerIndex0::iterator host = r.first; host != r.second; + for (HostContainerIndex0::iterator host = idx.lower_bound(t); host != idx.upper_bound(t); ++host) { storage.push_back(*host); } diff --git a/src/lib/dhcpsrv/cfg_option.h b/src/lib/dhcpsrv/cfg_option.h index 6af05259bc..d0dfc7eee7 100644 --- a/src/lib/dhcpsrv/cfg_option.h +++ b/src/lib/dhcpsrv/cfg_option.h @@ -303,6 +303,10 @@ public: /// name, or an uint32_t value, in which case it specifies a vendor /// identifier. /// + /// @note If there are multiple options with the same key, only one will + /// be returned. No indication will be given of the presence of others, + /// and the instance returned is not determinable. + /// /// @param key Option space name or vendor identifier. /// @param option_code Code of the option to be returned. /// @tparam Selector one of: @c std::string or @c uint32_t @@ -312,18 +316,21 @@ public: template OptionDescriptor get(const Selector& key, const uint16_t option_code) const { + + // Check for presence of options. OptionContainerPtr options = getAll(key); if (!options || options->empty()) { return (OptionDescriptor(false)); } + // Some options present, locate the one we are interested in. const OptionContainerTypeIndex& idx = options->get<1>(); - const OptionContainerTypeRange& range = idx.equal_range(option_code); - if (std::distance(range.first, range.second) == 0) { + OptionContainerTypeIndex::const_iterator od_itr = idx.find(option_code); + if (od_itr == idx.end()) { return (OptionDescriptor(false)); } - return (*range.first); + return (*od_itr); } /// @brief Converts option space name to vendor id.