mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 07:57:30 +02:00
possible fix for entity server crash
This commit is contained in:
parent
ade6bf24bb
commit
ae8879a558
3 changed files with 8 additions and 5 deletions
|
@ -376,9 +376,7 @@ void EntityServer::nodeAdded(SharedNodePointer node) {
|
||||||
|
|
||||||
void EntityServer::nodeKilled(SharedNodePointer node) {
|
void EntityServer::nodeKilled(SharedNodePointer node) {
|
||||||
EntityTreePointer tree = std::static_pointer_cast<EntityTree>(_tree);
|
EntityTreePointer tree = std::static_pointer_cast<EntityTree>(_tree);
|
||||||
tree->withWriteLock([&] {
|
tree->deleteDescendantsOfAvatar(node->getUUID());
|
||||||
tree->deleteDescendantsOfAvatar(node->getUUID());
|
|
||||||
});
|
|
||||||
tree->forgetAvatarID(node->getUUID());
|
tree->forgetAvatarID(node->getUUID());
|
||||||
OctreeServer::nodeKilled(node);
|
OctreeServer::nodeKilled(node);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2213,6 +2213,7 @@ void EntityTree::fixupNeedsParentFixups() {
|
||||||
|
|
||||||
entity->postParentFixup();
|
entity->postParentFixup();
|
||||||
} else if (getIsServer() || _avatarIDs.contains(entity->getParentID())) {
|
} else if (getIsServer() || _avatarIDs.contains(entity->getParentID())) {
|
||||||
|
std::lock_guard<std::mutex> lock(_childrenOfAvatarsLock);
|
||||||
// this is a child of an avatar, which the entity server will never have
|
// this is a child of an avatar, which the entity server will never have
|
||||||
// a SpatiallyNestable object for. Add it to a list for cleanup when the avatar leaves.
|
// a SpatiallyNestable object for. Add it to a list for cleanup when the avatar leaves.
|
||||||
if (!_childrenOfAvatars.contains(entity->getParentID())) {
|
if (!_childrenOfAvatars.contains(entity->getParentID())) {
|
||||||
|
@ -2241,6 +2242,7 @@ void EntityTree::fixupNeedsParentFixups() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void EntityTree::deleteDescendantsOfAvatar(QUuid avatarID) {
|
void EntityTree::deleteDescendantsOfAvatar(QUuid avatarID) {
|
||||||
|
std::lock_guard<std::mutex> lock(_childrenOfAvatarsLock);
|
||||||
QHash<QUuid, QSet<EntityItemID>>::const_iterator itr = _childrenOfAvatars.constFind(avatarID);
|
QHash<QUuid, QSet<EntityItemID>>::const_iterator itr = _childrenOfAvatars.constFind(avatarID);
|
||||||
if (itr != _childrenOfAvatars.end()) {
|
if (itr != _childrenOfAvatars.end()) {
|
||||||
if (!itr.value().empty()) {
|
if (!itr.value().empty()) {
|
||||||
|
@ -2259,8 +2261,10 @@ void EntityTree::deleteDescendantsOfAvatar(QUuid avatarID) {
|
||||||
|
|
||||||
void EntityTree::removeFromChildrenOfAvatars(EntityItemPointer entity) {
|
void EntityTree::removeFromChildrenOfAvatars(EntityItemPointer entity) {
|
||||||
QUuid avatarID = entity->getParentID();
|
QUuid avatarID = entity->getParentID();
|
||||||
if (_childrenOfAvatars.contains(avatarID)) {
|
std::lock_guard<std::mutex> lock(_childrenOfAvatarsLock);
|
||||||
_childrenOfAvatars[avatarID].remove(entity->getID());
|
auto itr = _childrenOfAvatars.find(avatarID);
|
||||||
|
if (itr != _childrenOfAvatars.end()) {
|
||||||
|
itr.value().remove(entity->getID());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -366,6 +366,7 @@ protected:
|
||||||
|
|
||||||
// we maintain a list of avatarIDs to notice when an entity is a child of one.
|
// we maintain a list of avatarIDs to notice when an entity is a child of one.
|
||||||
QSet<QUuid> _avatarIDs; // IDs of avatars connected to entity server
|
QSet<QUuid> _avatarIDs; // IDs of avatars connected to entity server
|
||||||
|
std::mutex _childrenOfAvatarsLock;
|
||||||
QHash<QUuid, QSet<EntityItemID>> _childrenOfAvatars; // which entities are children of which avatars
|
QHash<QUuid, QSet<EntityItemID>> _childrenOfAvatars; // which entities are children of which avatars
|
||||||
|
|
||||||
float _maxTmpEntityLifetime { DEFAULT_MAX_TMP_ENTITY_LIFETIME };
|
float _maxTmpEntityLifetime { DEFAULT_MAX_TMP_ENTITY_LIFETIME };
|
||||||
|
|
Loading…
Reference in a new issue