few more unlikely but potential deadlock cases

locking in lokinet_shared needs revisited in general.  In addition, user-supplied
callbacks we call from the main thread currently should be called on a separate
thread instead, both to keep the main loop fast and to avoid complex locking issues.
pull/2141/head
Thomas Winget 1 year ago
parent 46736d1b95
commit cae709d8e0

@ -408,7 +408,6 @@ struct lokinet_srv_lookup_private
{
std::promise<int> promise;
{
auto lock = ctx->acquire();
if (ctx->impl and ctx->impl->IsUp())
{
ctx->impl->CallSafe([host, service, &promise, ctx, this]() {
@ -668,13 +667,15 @@ extern "C"
return;
}
auto lock = ctx->acquire();
if (auto itr = ctx->active_conns.find(remote); itr != ctx->active_conns.end())
{
result->success = true;
llarp::LogError("Active connection to {} already exists", remote);
return;
auto lock = ctx->acquire();
if (auto itr = ctx->active_conns.find(remote); itr != ctx->active_conns.end())
{
result->success = true;
llarp::LogError("Active connection to {} already exists", remote);
return;
}
}
if (not ctx->impl->IsUp())
@ -805,6 +806,7 @@ extern "C"
return;
}
auto lock = ctx->acquire();
ctx->outbound_tcp(remote, *result);
assert(result->error == 0);
return;
@ -829,7 +831,6 @@ extern "C"
return -1;
std::promise<int> promise;
{
auto lock = ctx->acquire();
if (not ctx->impl->IsUp())
{
return -1;

Loading…
Cancel
Save