0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2025-01-13 08:23:56 +01:00

ircd::server: Add asynchronous prelink() to interface.

This commit is contained in:
Jason Volk 2020-10-16 00:33:23 -07:00
parent 859c488932
commit 9d1741f5b4
2 changed files with 32 additions and 2 deletions

View file

@ -56,8 +56,9 @@ namespace ircd::server
peer &find(const net::hostport &);
// mutable utils
bool errclear(const net::hostport &);
peer &get(const net::hostport &); // creates the peer if not found.
peer &get(const net::hostport &); // creates the peer if not found.
bool prelink(const net::hostport &); // creates and links if not errant.
bool errclear(const net::hostport &); // clear cached error.
}
/// Subsystem initialization / destruction from ircd::main

View file

@ -124,6 +124,35 @@ ircd::server::init::interrupt()
// ircd::server
//
bool
ircd::server::prelink(const net::hostport &hostport)
try
{
auto &peer
{
get(hostport)
};
if(peer.err_has())
return false;
if(peer.links.empty())
peer.link_add(1);
return true;
}
catch(const std::exception &e)
{
log::error
{
log, "Prelink to '%s' :%s",
server::canonize(hostport),
e.what(),
};
return false;
}
ircd::server::peer &
ircd::server::get(const net::hostport &hostport)
{