Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
server/onesync: fix deadlock caused by accidental recursive acquisiti…
…on of a SRW lock
  • Loading branch information
blattersturm committed Apr 12, 2019
1 parent f8cd327 commit b741f9a
Showing 1 changed file with 7 additions and 4 deletions.
Expand Up @@ -1291,19 +1291,20 @@ void ServerGameState::HandleClientDrop(const std::shared_ptr<fx::Client>& client
}

{
std::shared_lock<std::shared_mutex> lock(m_entitiesByIdMutex);

auto entity = m_entitiesById[set & 0xFFFF];
std::weak_ptr<sync::SyncEntityState> entity;

{
std::shared_lock<std::shared_mutex> lock(m_entitiesByIdMutex);
entity = m_entitiesById[set & 0xFFFF];
}

auto entityRef = entity.lock();

if (entityRef)
{
OnCloneRemove(entityRef);
}
}
}

{
std::unique_lock<std::shared_mutex> entityListLock(m_entityListMutex);
Expand Down Expand Up @@ -1867,6 +1868,7 @@ void ServerGameState::AttachToObject(fx::ServerInstanceBase* instance)
auto [data, lock] = GetClientData(this, client);
int used = 0;

{
std::shared_lock<std::shared_mutex> entityListLock(m_entitiesByIdMutex);

for (auto object : data->objectIds)
Expand All @@ -1876,6 +1878,7 @@ void ServerGameState::AttachToObject(fx::ServerInstanceBase* instance)
used++;
}
}
}

console::Printf("net", "%s^7: %d/%d object IDs used/sent (%.2f percent)\n", client->GetName(), used, data->objectIds.size(), (used / (float)data->objectIds.size()) * 100.0f);
});
Expand Down

0 comments on commit b741f9a

Please sign in to comment.