diff --git a/OpenSim/Data/MySQL/MySQLUserData.cs b/OpenSim/Data/MySQL/MySQLUserData.cs index 677d287877..cd5ac39170 100644 --- a/OpenSim/Data/MySQL/MySQLUserData.cs +++ b/OpenSim/Data/MySQL/MySQLUserData.cs @@ -661,9 +661,7 @@ namespace OpenSim.Data.MySQL AvatarAppearance appearance = null; if (!m_appearanceMapper.TryGetValue(user.UUID, out appearance)) { - appearance = new AvatarAppearance(); - appearance.Owner = user; - UpdateUserAppearance(user, appearance); + appearance = null; } return appearance; } diff --git a/OpenSim/Data/UserDataBase.cs b/OpenSim/Data/UserDataBase.cs index 50325b23c8..57f45641ba 100644 --- a/OpenSim/Data/UserDataBase.cs +++ b/OpenSim/Data/UserDataBase.cs @@ -60,15 +60,12 @@ namespace OpenSim.Data public abstract void Initialise(string connect); public abstract List GeneratePickerResults(LLUUID queryID, string query); public AvatarAppearance GetUserAppearance(LLUUID user) { - AvatarAppearance aa; + AvatarAppearance aa = null; try { aa = aplist[user]; m_log.Info("[APPEARANCE] Found appearance for " + user.ToString() + aa.ToString()); } catch (System.Collections.Generic.KeyNotFoundException e) { - aplist[user] = new AvatarAppearance(); - aplist[user].Owner = user; - aa = aplist[user]; - m_log.Info("[APPEARANCE] Setting up default appearance for " + user.ToString() + aa.ToString()); + m_log.Info("[APPEARANCE] No appearance found for " + user.ToString()); } return aa; } diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs index 5a62682b9f..87e06f1204 100644 --- a/OpenSim/Framework/Communications/UserManagerBase.cs +++ b/OpenSim/Framework/Communications/UserManagerBase.cs @@ -611,7 +611,7 @@ namespace OpenSim.Framework.Communications m_log.InfoFormat("[USERSTORAGE]: Unable to find user appearance {0} via {1} ({2})", user.ToString(), plugin.Key, e.ToString()); } } - return new AvatarAppearance(); + return null; } public void UpdateUserAppearance(LLUUID user, AvatarAppearance appearance) diff --git a/OpenSim/Grid/UserServer/UserManager.cs b/OpenSim/Grid/UserServer/UserManager.cs index 307af3414a..1cf2a48e9e 100644 --- a/OpenSim/Grid/UserServer/UserManager.cs +++ b/OpenSim/Grid/UserServer/UserManager.cs @@ -256,7 +256,13 @@ namespace OpenSim.Grid.UserServer if (requestData.Contains("owner")) { appearance = GetUserAppearance(new LLUUID((string)requestData["owner"])); - responseData = appearance.ToHashTable(); + if (appearance == null) { + responseData = new Hashtable(); + responseData["error_type"] = "no appearance"; + responseData["error_desc"] = "There was no appearance found for this avatar"; + } else { + responseData = appearance.ToHashTable(); + } } else { diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index e1764b5996..d02d22f9cb 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs @@ -1780,28 +1780,27 @@ namespace OpenSim.Region.Environment.Scenes protected virtual ScenePresence CreateAndAddScenePresence(IClientAPI client, bool child) { - AvatarAppearance appearance = CommsManager.UserService.GetUserAppearance(client.AgentId); + + AvatarAppearance appearance = null; + GetAvatarAppearance(client, out appearance); ScenePresence avatar = m_innerScene.CreateAndAddScenePresence(client, child, appearance); return avatar; } - // protected void GetAvatarAppearance(IClientAPI client, out AvatarAppearance appearance) - // { - // appearance = CommsManager.UserService.GetUserAppearance(client.AgentId); + protected void GetAvatarAppearance(IClientAPI client, out AvatarAppearance appearance) + { + appearance = CommsManager.UserService.GetUserAppearance(client.AgentId); - // // if (m_AvatarFactory == null || - // // !m_AvatarFactory.TryGetAvatarAppearance(client.AgentId, out appearance)) - // // { - // // //not found Appearance - // // m_log.Warn("[AVATAR DEBUGGING]: Couldn't fetch avatar appearance from factory, please report this to the opensim mantis"); - // // byte[] visualParams; - // // AvatarWearable[] wearables; - // // GetDefaultAvatarAppearance(out wearables, out visualParams); - // // appearance = new AvatarAppearance(client.AgentId, wearables, visualParams); - // // } - // } + if (m_AvatarFactory == null || + !m_AvatarFactory.TryGetAvatarAppearance(client.AgentId, out appearance)) + { + // not found Appearance + m_log.Warn("[AVATAR DEBUGGING]: Couldn't fetch avatar appearance from factory, please report this to the opensim mantis"); + appearance = new AvatarAppearance(); + } + } /// /// Remove the given client from the scene. diff --git a/OpenSim/Region/Modules/AvatarFactory/AvatarFactoryModule.cs b/OpenSim/Region/Modules/AvatarFactory/AvatarFactoryModule.cs index 3ac8e9a15d..7dae702772 100644 --- a/OpenSim/Region/Modules/AvatarFactory/AvatarFactoryModule.cs +++ b/OpenSim/Region/Modules/AvatarFactory/AvatarFactoryModule.cs @@ -59,112 +59,114 @@ namespace OpenSim.Region.Modules.AvatarFactory public bool TryGetAvatarAppearance(LLUUID avatarId, out AvatarAppearance appearance) { + appearance = m_scene.CommsManager.UserService.GetUserAppearance(avatarId); + return true; - //should only let one thread at a time do this part - EventWaitHandle waitHandle = null; - bool fetchInProgress = false; - lock (m_syncLock) - { - appearance = CheckCache(avatarId); - if (appearance != null) - { - return true; - } + // //should only let one thread at a time do this part + // EventWaitHandle waitHandle = null; + // bool fetchInProgress = false; + // lock (m_syncLock) + // { + // appearance = CheckCache(avatarId); + // if (appearance != null) + // { + // return true; + // } - //not in cache so check to see if another thread is already fetching it - if (m_fetchesInProgress.TryGetValue(avatarId, out waitHandle)) - { - fetchInProgress = true; - } - else - { - fetchInProgress = false; + // //not in cache so check to see if another thread is already fetching it + // if (m_fetchesInProgress.TryGetValue(avatarId, out waitHandle)) + // { + // fetchInProgress = true; + // } + // else + // { + // fetchInProgress = false; - //no thread already fetching this appearance, so add a wait handle to list - //for any following threads that want the same appearance - waitHandle = new EventWaitHandle(false, EventResetMode.ManualReset); - m_fetchesInProgress.Add(avatarId, waitHandle); - } - } + // //no thread already fetching this appearance, so add a wait handle to list + // //for any following threads that want the same appearance + // waitHandle = new EventWaitHandle(false, EventResetMode.ManualReset); + // m_fetchesInProgress.Add(avatarId, waitHandle); + // } + // } - if (fetchInProgress) - { - waitHandle.WaitOne(); - appearance = CheckCache(avatarId); - if (appearance != null) - { - waitHandle = null; - return true; - } - else - { - waitHandle = null; - return false; - } - } - else - { - // BUG: !? (Reduced from 5000 to 500 by Adam) - Thread.Sleep(500); //why is this here? + // if (fetchInProgress) + // { + // waitHandle.WaitOne(); + // appearance = CheckCache(avatarId); + // if (appearance != null) + // { + // waitHandle = null; + // return true; + // } + // else + // { + // waitHandle = null; + // return false; + // } + // } + // else + // { + // // BUG: !? (Reduced from 5000 to 500 by Adam) + // Thread.Sleep(500); //why is this here? - //this is the first thread to request this appearance - //so let it check the db and if not found then create a default appearance - //and add that to the cache - appearance = CheckDatabase(avatarId); - if (appearance != null) - { - //appearance has now been added to cache so lets pulse any waiting threads - lock (m_syncLock) - { - m_fetchesInProgress.Remove(avatarId); - waitHandle.Set(); - } - // waitHandle.Close(); - waitHandle = null; - return true; - } + // //this is the first thread to request this appearance + // //so let it check the db and if not found then create a default appearance + // //and add that to the cache + // appearance = CheckDatabase(avatarId); + // if (appearance != null) + // { + // //appearance has now been added to cache so lets pulse any waiting threads + // lock (m_syncLock) + // { + // m_fetchesInProgress.Remove(avatarId); + // waitHandle.Set(); + // } + // // waitHandle.Close(); + // waitHandle = null; + // return true; + // } - //not found a appearance for the user, so create a new default one - appearance = CreateDefault(avatarId); - if (appearance != null) - { - //update database - if (m_enablePersist) - { - m_appearanceMapper.Add(avatarId.UUID, appearance); - } + // //not found a appearance for the user, so create a new default one + // appearance = CreateDefault(avatarId); + // if (appearance != null) + // { + // //update database + // if (m_enablePersist) + // { + // m_appearanceMapper.Add(avatarId.UUID, appearance); + // } - //add appearance to dictionary cache - lock (m_avatarsAppearance) - { - m_avatarsAppearance[avatarId] = appearance; - } + // //add appearance to dictionary cache + // lock (m_avatarsAppearance) + // { + // m_avatarsAppearance[avatarId] = appearance; + // } - //appearance has now been added to cache so lets pulse any waiting threads - lock (m_syncLock) - { - m_fetchesInProgress.Remove(avatarId); - waitHandle.Set(); - } - // waitHandle.Close(); - waitHandle = null; - return true; - } - else - { - //something went wrong, so release the wait handle and remove it - //all waiting threads will fail to find cached appearance - //but its better for them to fail than wait for ever - lock (m_syncLock) - { - m_fetchesInProgress.Remove(avatarId); - waitHandle.Set(); - } - //waitHandle.Close(); - waitHandle = null; - return false; - } - } + // //appearance has now been added to cache so lets pulse any waiting threads + // lock (m_syncLock) + // { + // m_fetchesInProgress.Remove(avatarId); + // waitHandle.Set(); + // } + // // waitHandle.Close(); + // waitHandle = null; + // return true; + // } + // else + // { + // //something went wrong, so release the wait handle and remove it + // //all waiting threads will fail to find cached appearance + // //but its better for them to fail than wait for ever + // lock (m_syncLock) + // { + // m_fetchesInProgress.Remove(avatarId); + // waitHandle.Set(); + // } + // //waitHandle.Close(); + // waitHandle = null; + // return false; + // } + // } } private AvatarAppearance CreateDefault(LLUUID avatarId)