From 7b062cefa22a5b67e124e478345751bab7a18093 Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Thu, 3 Jan 2008 14:01:53 +0000 Subject: * Added removal of TextureSenders and UserTextureDownloadService on agent leaving region. --- .../Environment/Modules/TextureDownloadModule.cs | 18 +++++++++++++++++- .../Environment/Modules/UserTextureDownloadService.cs | 15 ++++++++++++++- 2 files changed, 31 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Environment/Modules') diff --git a/OpenSim/Region/Environment/Modules/TextureDownloadModule.cs b/OpenSim/Region/Environment/Modules/TextureDownloadModule.cs index 4e96572..6ebf47f 100644 --- a/OpenSim/Region/Environment/Modules/TextureDownloadModule.cs +++ b/OpenSim/Region/Environment/Modules/TextureDownloadModule.cs @@ -49,7 +49,7 @@ namespace OpenSim.Region.Environment.Modules private readonly BlockingQueue m_queueSenders = new BlockingQueue(); - private Dictionary m_userTextureServices = + private readonly Dictionary m_userTextureServices = new Dictionary(); private Thread m_thread; @@ -73,6 +73,22 @@ namespace OpenSim.Region.Environment.Modules m_scenes.Add(scene); m_scene = scene; m_scene.EventManager.OnNewClient += NewClient; + m_scene.EventManager.OnRemovePresence += EventManager_OnRemovePresence; + } + } + + private void EventManager_OnRemovePresence(LLUUID agentId) + { + UserTextureDownloadService textureService; + + lock (m_userTextureServices) + { + if( m_userTextureServices.TryGetValue( agentId, out textureService )) + { + textureService.Close(); + + m_userTextureServices.Remove(agentId); + } } } diff --git a/OpenSim/Region/Environment/Modules/UserTextureDownloadService.cs b/OpenSim/Region/Environment/Modules/UserTextureDownloadService.cs index 9a5b362..5e768ee 100644 --- a/OpenSim/Region/Environment/Modules/UserTextureDownloadService.cs +++ b/OpenSim/Region/Environment/Modules/UserTextureDownloadService.cs @@ -94,5 +94,18 @@ namespace OpenSim.Region.Environment.Modules m_sharedSendersQueue.Enqueue(textureSender); } } + + internal void Close() + { + lock (m_textureSenders) + { + foreach( TextureSender textureSender in m_textureSenders.Values ) + { + textureSender.Cancel = true; + } + + m_textureSenders.Clear(); + } + } } -} \ No newline at end of file +} -- cgit v1.1