diff --git a/ircd/server.cc b/ircd/server.cc index 6984b38f7..c9917ce87 100644 --- a/ircd/server.cc +++ b/ircd/server.cc @@ -183,7 +183,18 @@ ircd::server::get(const net::hostport &hostport) if(it == peers.end() || it->first != hostcanon) it = create(hostport, it); - return *it->second; + auto &peer + { + *it->second + }; + + if(peer.expired() && !peer.op_resolve) + { + assert(peer.hostcanon.data() == it->first.data()); + peer.resolve(peer.open_opts.hostport); + } + + return peer; } decltype(ircd::server::peers)::iterator @@ -206,9 +217,7 @@ ircd::server::create(const net::hostport &hostport, assert(!empty(peer->hostcanon)); const string_view key{peer->hostcanon}; it = peers.emplace_hint(it, key, std::move(peer)); - assert(it->second->hostcanon.data() == it->first.data()); - it->second->resolve(it->second->open_opts.hostport); return it; } @@ -2104,6 +2113,9 @@ ircd::server::link::open(const net::open_opts &open_opts) if(op_init) return false; + if(opened()) + return false; + auto handler { std::bind(&link::handle_open, this, ph::_1)