mirror of
https://github.com/oxen-io/lokinet
synced 2023-12-14 06:53:00 +01:00
avoid potential deadlock
This commit is contained in:
parent
fc19707471
commit
46736d1b95
|
@ -886,15 +886,24 @@ extern "C"
|
|||
{
|
||||
if (not ctx)
|
||||
return;
|
||||
auto lock = ctx->acquire();
|
||||
if (not ctx->impl->IsUp())
|
||||
return;
|
||||
|
||||
{
|
||||
auto lock = ctx->acquire();
|
||||
if (not ctx->impl->IsUp())
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
std::promise<void> promise;
|
||||
bool inbound = ctx->tcp_conns.at(tcp_id);
|
||||
bool inbound{false};
|
||||
{
|
||||
auto lock = ctx->acquire();
|
||||
inbound = ctx->tcp_conns.at(tcp_id);
|
||||
}
|
||||
|
||||
ctx->impl->CallSafe([tcp_id, inbound, ctx, &promise]() {
|
||||
auto lock = ctx->acquire();
|
||||
auto ep = ctx->endpoint();
|
||||
auto* quic = ep->GetQUICTunnel();
|
||||
try
|
||||
|
@ -908,10 +917,14 @@ extern "C"
|
|||
{}
|
||||
promise.set_value();
|
||||
});
|
||||
for (auto& itr : ctx->active_conns)
|
||||
|
||||
{
|
||||
if (itr.second.tcp_id == tcp_id)
|
||||
ctx->active_conns.erase(itr.first);
|
||||
auto lock = ctx->acquire();
|
||||
for (auto& itr : ctx->active_conns)
|
||||
{
|
||||
if (itr.second.tcp_id == tcp_id)
|
||||
ctx->active_conns.erase(itr.first);
|
||||
}
|
||||
}
|
||||
promise.get_future().get();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue