From 3f4faec15ff7aef8e0971e12dc47ee3e158f52fd Mon Sep 17 00:00:00 2001 From: howard-stearns Date: Tue, 20 Dec 2016 16:14:59 -0800 Subject: [PATCH 1/2] Fix idententity packet in AC --- libraries/avatars/src/AvatarHashMap.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/libraries/avatars/src/AvatarHashMap.cpp b/libraries/avatars/src/AvatarHashMap.cpp index ffb945df4c..241568aab3 100644 --- a/libraries/avatars/src/AvatarHashMap.cpp +++ b/libraries/avatars/src/AvatarHashMap.cpp @@ -134,11 +134,16 @@ void AvatarHashMap::processAvatarIdentityPacket(QSharedPointer // make sure this isn't for an ignored avatar auto nodeList = DependencyManager::get(); static auto EMPTY = QUuid(); - if (identity.uuid == _avatarHash.value(EMPTY)->getSessionUUID()) { - // We add MyAvatar to _avatarHash with an empty UUID. Code relies on this. In order to correctly handle an - // identity packet for ourself (such as when we are assigned a sessionDisplayName by the mixer upon joining), - // we make things match here. - identity.uuid = EMPTY; + + { + QWriteLocker locker(&_hashLock); + auto me = _avatarHash.find(EMPTY); + if ((me != _avatarHash.end()) && (identity.uuid == me.value()->getSessionUUID())) { + // We add MyAvatar to _avatarHash with an empty UUID. Code relies on this. In order to correctly handle an + // identity packet for ourself (such as when we are assigned a sessionDisplayName by the mixer upon joining), + // we make things match here. + identity.uuid = EMPTY; + } } if (!nodeList->isIgnoringNode(identity.uuid)) { // mesh URL for a UUID, find avatar in our list From a6e353d75f034005437297e3eb3aa9c21d49b743 Mon Sep 17 00:00:00 2001 From: howard-stearns Date: Tue, 20 Dec 2016 16:25:23 -0800 Subject: [PATCH 2/2] read lock, not write --- libraries/avatars/src/AvatarHashMap.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/avatars/src/AvatarHashMap.cpp b/libraries/avatars/src/AvatarHashMap.cpp index 241568aab3..8871769261 100644 --- a/libraries/avatars/src/AvatarHashMap.cpp +++ b/libraries/avatars/src/AvatarHashMap.cpp @@ -136,7 +136,7 @@ void AvatarHashMap::processAvatarIdentityPacket(QSharedPointer static auto EMPTY = QUuid(); { - QWriteLocker locker(&_hashLock); + QReadLocker locker(&_hashLock); auto me = _avatarHash.find(EMPTY); if ((me != _avatarHash.end()) && (identity.uuid == me.value()->getSessionUUID())) { // We add MyAvatar to _avatarHash with an empty UUID. Code relies on this. In order to correctly handle an