Remove duplicate connection closing method

`deregister_peer` does the exact same thing as `close_connection` so
just remove it.

Also removes an unnecessary loop dispatch call (because we *have* to be
in the logic thread already to be able to touch the variables we are
touching before the dispatch).
This commit is contained in:
Jason Rhinelander 2023-12-08 19:02:14 -04:00 committed by dr7ana
parent ed87b73f23
commit be613734b4
4 changed files with 10 additions and 52 deletions

@ -1 +1 @@
Subproject commit f903a8f6d08398c591c9fd12e93a3c35c5fa65c7
Subproject commit fdc8b2a514c3da0012adfcb6a0d08809c1bc5e06

View File

@ -51,27 +51,6 @@ namespace llarp
return false;
}
bool
Endpoint::deregister_peer(RouterID _rid)
{
if (auto itr = conns.find(_rid); itr != conns.end())
{
auto& c = itr->second;
auto& _scid = c->conn->scid();
link_manager._router.loop()->call([this, scid = _scid, rid = _rid]() {
endpoint->close_connection(scid);
conns.erase(rid);
connid_map.erase(scid);
});
return true;
}
return false;
}
size_t
Endpoint::num_connected(bool clients_only) const
{
@ -111,18 +90,15 @@ namespace llarp
void
Endpoint::close_connection(RouterID _rid)
{
if (auto itr = conns.find(_rid); itr != conns.end())
{
auto& c = itr->second;
auto& _scid = c->conn->scid();
assert(link_manager._router.loop()->inEventLoop());
auto itr = conns.find(_rid);
if (itr != conns.end())
return;
link_manager._router.loop()->call([this, scid = _scid, rid = _rid]() {
endpoint->close_connection(scid);
conns.erase(rid);
connid_map.erase(scid);
});
}
auto& conn = *itr->second->conn;
conn.close_connection();
connid_map.erase(conn.scid());
conns.erase(itr);
}
} // namespace link
@ -464,18 +440,6 @@ namespace llarp
return ep.have_conn(remote, true);
}
void
LinkManager::deregister_peer(RouterID remote)
{
if (auto rv = ep.deregister_peer(remote); rv)
{
persisting_conns.erase(remote);
log::info(logcat, "Peer {} successfully de-registered", remote);
}
else
log::warning(logcat, "Peer {} not found for de-registration!", remote);
}
void
LinkManager::stop()
{

View File

@ -61,9 +61,6 @@ namespace llarp
bool
have_conn(const RouterID& remote, bool client_only) const;
bool
deregister_peer(RouterID remote);
size_t
num_connected(bool clients_only) const;
@ -268,9 +265,6 @@ namespace llarp
bool
have_client_connection_to(const RouterID& remote) const;
void
deregister_peer(RouterID remote);
void
test_reachability(const RouterID& rid, conn_open_hook, conn_closed_hook);

View File

@ -981,7 +981,7 @@ namespace llarp
// mark peers as de-registered
for (auto& peer : close_peers)
_link_manager.deregister_peer(peer);
_link_manager.close_connection(peer);
}
*/