From 3a56d91974db98116b8e524dd5fe0d661df30b19 Mon Sep 17 00:00:00 2001 From: diva Date: Thu, 18 Dec 2008 18:11:29 +0000 Subject: This may fix mantis #2855. There was a race condition on the TextureDownloadModule upon clients (ScenePresences) being closed. If there were still textures to send, the UserTextureServices was created again, but pointing to the old IClient that had just been closed, which made things not work upon that user returning to that region. --- .../Agent/TextureDownload/TextureDownloadModule.cs | 58 ++++++++++++++++++---- 1 file changed, 49 insertions(+), 9 deletions(-) diff --git a/OpenSim/Region/Environment/Modules/Agent/TextureDownload/TextureDownloadModule.cs b/OpenSim/Region/Environment/Modules/Agent/TextureDownload/TextureDownloadModule.cs index a7ad37d..35fa5ed 100644 --- a/OpenSim/Region/Environment/Modules/Agent/TextureDownload/TextureDownloadModule.cs +++ b/OpenSim/Region/Environment/Modules/Agent/TextureDownload/TextureDownloadModule.cs @@ -121,7 +121,7 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureDownload if (m_userTextureServices.TryGetValue(agentId, out textureService)) { textureService.Close(); - m_log.DebugFormat("[TEXTURE MODULE]: Removing UserTextureServices from {0}", m_scene.RegionInfo.RegionName); + //m_log.DebugFormat("[TEXTURE MODULE]: Removing UserTextureServices from {0}", m_scene.RegionInfo.RegionName); m_userTextureServices.Remove(agentId); } } @@ -129,17 +129,60 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureDownload public void NewClient(IClientAPI client) { + UserTextureDownloadService textureService; + + lock (m_userTextureServices) + { + if (m_userTextureServices.TryGetValue(client.AgentId, out textureService)) + { + textureService.Close(); + //m_log.DebugFormat("[TEXTURE MODULE]: Removing outdated UserTextureServices from {0}", m_scene.RegionInfo.RegionName); + m_userTextureServices.Remove(client.AgentId); + } + m_userTextureServices.Add(client.AgentId, new UserTextureDownloadService(client, m_scene, m_queueSenders)); + } + client.OnRequestTexture += TextureRequest; } + /// I'm commenting this out, and replacing it with the implementation below, which + /// may return a null value. This is necessary for avoiding race conditions + /// recreating UserTextureServices for clients that have just been closed. + /// That behavior of always returning a UserTextureServices was causing the + /// A-B-A problem (mantis #2855). + /// + ///// + ///// Does this user have a registered texture download service? + ///// + ///// + ///// + ///// Always returns true, since a service is created if one does not already exist + //private bool TryGetUserTextureService( + // IClientAPI client, out UserTextureDownloadService textureService) + //{ + // lock (m_userTextureServices) + // { + // if (m_userTextureServices.TryGetValue(client.AgentId, out textureService)) + // { + // //m_log.DebugFormat("[TEXTURE MODULE]: Found existing UserTextureServices in ", m_scene.RegionInfo.RegionName); + // return true; + // } + + // m_log.DebugFormat("[TEXTURE MODULE]: Creating new UserTextureServices in ", m_scene.RegionInfo.RegionName); + // textureService = new UserTextureDownloadService(client, m_scene, m_queueSenders); + // m_userTextureServices.Add(client.AgentId, textureService); + + // return true; + // } + //} + /// /// Does this user have a registered texture download service? /// /// /// - /// Always returns true, since a service is created if one does not already exist - private bool TryGetUserTextureService( - IClientAPI client, out UserTextureDownloadService textureService) + /// A UserTextureDownloadService or null in the output parameter, and true or false accordingly. + private bool TryGetUserTextureService(IClientAPI client, out UserTextureDownloadService textureService) { lock (m_userTextureServices) { @@ -149,11 +192,8 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureDownload return true; } - m_log.DebugFormat("[TEXTURE MODULE]: Creating new UserTextureServices in ", m_scene.RegionInfo.RegionName); - textureService = new UserTextureDownloadService(client, m_scene, m_queueSenders); - m_userTextureServices.Add(client.AgentId, textureService); - - return true; + textureService = null; + return false; } } -- cgit v1.1