Verified Commit 139fcc1f authored by Alberto Miranda's avatar Alberto Miranda ♨️
Browse files

Fix std::vector bug when determining hosts

parent 23cdcf1c
Loading
Loading
Loading
Loading
Loading
+4 −7
Original line number Diff line number Diff line
@@ -162,7 +162,7 @@ void load_hosts() {
    bool local_host_found = false;

    std::vector<hermes::endpoint> addrs;
    addrs.reserve(hosts.size());
    addrs.resize(hosts.size());

    vector<uint64_t> host_ids(hosts.size());
    // populate vector with [0, ..., host_size - 1]
@@ -182,10 +182,7 @@ void load_hosts() {
         const auto& hostname = hosts.at(id).first;
         const auto& uri = hosts.at(id).second;

        auto endp = ::lookup_endpoint(uri);

        auto it = std::next(addrs.begin(), id);
        addrs.emplace(it, endp);
        addrs[id] = ::lookup_endpoint(uri);

        if (!local_host_found && hostname == local_hostname) {
            CTX->log()->debug("{}() Found local host: {}", __func__, hostname);