From be20f41637b6c06ce3ab16bc25851b6e43468e12 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Wed, 30 Apr 2008 21:43:47 +0000 Subject: * Cruft removal step #1. Cleaning Modules directory. --- .../Agent/TextureDownload/TextureDownloadModule.cs | 66 +++++++++-------- .../Agent/TextureDownload/TextureNotFoundSender.cs | 51 +++++++------ .../TextureDownload/UserTextureDownloadService.cs | 85 +++++++++++----------- 3 files changed, 104 insertions(+), 98 deletions(-) (limited to 'OpenSim/Region/Environment/Modules/Agent/TextureDownload') diff --git a/OpenSim/Region/Environment/Modules/Agent/TextureDownload/TextureDownloadModule.cs b/OpenSim/Region/Environment/Modules/Agent/TextureDownload/TextureDownloadModule.cs index b8899d2..ae2df69 100644 --- a/OpenSim/Region/Environment/Modules/Agent/TextureDownload/TextureDownloadModule.cs +++ b/OpenSim/Region/Environment/Modules/Agent/TextureDownload/TextureDownloadModule.cs @@ -40,14 +40,11 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureDownload { //private static readonly log4net.ILog m_log // = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); - - private Scene m_scene; - private List m_scenes = new List(); /// /// There is one queue for all textures waiting to be sent, regardless of the requesting user. /// - private readonly BlockingQueue m_queueSenders + private readonly BlockingQueue m_queueSenders = new BlockingQueue(); /// @@ -56,12 +53,17 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureDownload private readonly Dictionary m_userTextureServices = new Dictionary(); + private Scene m_scene; + private List m_scenes = new List(); + private Thread m_thread; public TextureDownloadModule() { } + #region IRegionModule Members + public void Initialise(Scene scene, IConfigSource config) { if (m_scene == null) @@ -83,6 +85,26 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureDownload } } + public void PostInitialise() + { + } + + public void Close() + { + } + + public string Name + { + get { return "TextureDownloadModule"; } + } + + public bool IsSharedModule + { + get { return false; } + } + + #endregion + /// /// Cleanup the texture service related objects for the removed presence. /// @@ -102,24 +124,6 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureDownload } } - public void PostInitialise() - { - } - - public void Close() - { - } - - public string Name - { - get { return "TextureDownloadModule"; } - } - - public bool IsSharedModule - { - get { return false; } - } - public void NewClient(IClientAPI client) { client.OnRequestTexture += TextureRequest; @@ -143,7 +147,7 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureDownload textureService = new UserTextureDownloadService(client, m_scene, m_queueSenders); m_userTextureServices.Add(client.AgentId, textureService); - + return true; } } @@ -157,11 +161,11 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureDownload { IClientAPI client = (IClientAPI) sender; UserTextureDownloadService textureService; - + if (TryGetUserTextureService(client, out textureService)) { textureService.HandleTextureRequest(e); - } + } } /// @@ -170,11 +174,11 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureDownload public void ProcessTextureSenders() { ITextureSender sender = null; - + while (true) { sender = m_queueSenders.Dequeue(); - + if (sender.Cancel) { TextureSent(sender); @@ -193,10 +197,10 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureDownload m_queueSenders.Enqueue(sender); } } - + // Make sure that any sender we currently have can get garbage collected sender = null; - + //m_log.InfoFormat("[TEXTURE DOWNLOAD] Texture sender queue size: {0}", m_queueSenders.Count()); } } @@ -207,9 +211,9 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureDownload /// private void TextureSent(ITextureSender sender) { - sender.Sending = false; + sender.Sending = false; //m_log.DebugFormat("[TEXTURE DOWNLOAD]: Removing download stat for {0}", sender.assetID); - m_scene.AddPendingDownloads(-1); + m_scene.AddPendingDownloads(-1); } } } \ No newline at end of file diff --git a/OpenSim/Region/Environment/Modules/Agent/TextureDownload/TextureNotFoundSender.cs b/OpenSim/Region/Environment/Modules/Agent/TextureDownload/TextureNotFoundSender.cs index 6f11f73..b181d20 100644 --- a/OpenSim/Region/Environment/Modules/Agent/TextureDownload/TextureNotFoundSender.cs +++ b/OpenSim/Region/Environment/Modules/Agent/TextureDownload/TextureNotFoundSender.cs @@ -39,55 +39,60 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureDownload { //private static readonly log4net.ILog m_log // = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); - - private LLUUID m_textureId; + + private bool m_cancel = false; private IClientAPI m_client; - + // See ITextureSender - public bool Sending - { - get { return false; } - set { m_sending = value; } - } - - private bool m_sending = false; + + private bool m_sending = false; + private LLUUID m_textureId; // See ITextureSender - public bool Cancel - { - get { return false; } - set { m_cancel = value; } - } - - private bool m_cancel = false; - + public TextureNotFoundSender(IClientAPI client, LLUUID textureID) { m_client = client; m_textureId = textureID; } - + + #region ITextureSender Members + + public bool Sending + { + get { return false; } + set { m_sending = value; } + } + + public bool Cancel + { + get { return false; } + set { m_cancel = value; } + } + // See ITextureSender public void UpdateRequest(int discardLevel, uint packetNumber) { // Not need to implement since priority changes don't affect this operation } - + // See ITextureSender public bool SendTexturePacket() { //m_log.InfoFormat( // "[TEXTURE NOT FOUND SENDER]: Informing the client that texture {0} cannot be found", // m_textureId); - + ImageNotInDatabasePacket notFound = new ImageNotInDatabasePacket(); notFound.ImageID.ID = m_textureId; - + // XXX Temporarily disabling as this appears to be causing client crashes on at least // 1.19.0(5) of the Linden Second Life client. // m_client.OutPacket(notFound, ThrottleOutPacketType.Texture); - + return true; } + + #endregion } } \ No newline at end of file diff --git a/OpenSim/Region/Environment/Modules/Agent/TextureDownload/UserTextureDownloadService.cs b/OpenSim/Region/Environment/Modules/Agent/TextureDownload/UserTextureDownloadService.cs index 08a22d6..4f63fd0 100644 --- a/OpenSim/Region/Environment/Modules/Agent/TextureDownload/UserTextureDownloadService.cs +++ b/OpenSim/Region/Environment/Modules/Agent/TextureDownload/UserTextureDownloadService.cs @@ -32,8 +32,6 @@ using log4net; using OpenSim.Framework; using OpenSim.Framework.Communications.Limit; using OpenSim.Region.Environment.Interfaces; -using OpenSim.Region.Environment.Modules.Agent.TextureDownload; -using OpenSim.Region.Environment.Modules.Agent.TextureSender; using OpenSim.Region.Environment.Scenes; namespace OpenSim.Region.Environment.Modules.Agent.TextureDownload @@ -45,7 +43,7 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureDownload /// public class UserTextureDownloadService { - private static readonly ILog m_log + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); /// @@ -56,35 +54,34 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureDownload /// sophisticated way. /// private static readonly int MAX_ALLOWED_TEXTURE_REQUESTS = 5; - - /// - /// We're going to limit requests for the same missing texture. - /// XXX This is really a temporary solution to deal with the situation where a client continually requests - /// the same missing textures - /// - private readonly IRequestLimitStrategy missingTextureLimitStrategy - = new RepeatLimitStrategy(MAX_ALLOWED_TEXTURE_REQUESTS); - + /// /// XXX Also going to limit requests for found textures. /// - private readonly IRequestLimitStrategy foundTextureLimitStrategy - = new RepeatLimitStrategy(MAX_ALLOWED_TEXTURE_REQUESTS); - - /// - /// Holds texture senders before they have received the appropriate texture from the asset cache. - /// - private readonly Dictionary m_textureSenders = new Dictionary(); - + private readonly IRequestLimitStrategy foundTextureLimitStrategy + = new RepeatLimitStrategy(MAX_ALLOWED_TEXTURE_REQUESTS); + + private readonly IClientAPI m_client; + private readonly Scene m_scene; + /// /// Texture Senders are placed in this queue once they have received their texture from the asset /// cache. Another module actually invokes the send. /// private readonly BlockingQueue m_sharedSendersQueue; - - private readonly Scene m_scene; - - private readonly IClientAPI m_client; + + /// + /// Holds texture senders before they have received the appropriate texture from the asset cache. + /// + private readonly Dictionary m_textureSenders = new Dictionary(); + + /// + /// We're going to limit requests for the same missing texture. + /// XXX This is really a temporary solution to deal with the situation where a client continually requests + /// the same missing textures + /// + private readonly IRequestLimitStrategy missingTextureLimitStrategy + = new RepeatLimitStrategy(MAX_ALLOWED_TEXTURE_REQUESTS); public UserTextureDownloadService( IClientAPI client, Scene scene, BlockingQueue sharedQueue) @@ -112,19 +109,19 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureDownload { // If we've received new non UUID information for this request and it hasn't dispatched // yet, then update the request accordingly. - textureSender.UpdateRequest(e.DiscardLevel, e.PacketNumber); + textureSender.UpdateRequest(e.DiscardLevel, e.PacketNumber); } else - { + { if (!foundTextureLimitStrategy.AllowRequest(e.RequestedAssetID)) { // m_log.DebugFormat( // "[USER TEXTURE DOWNLOAD SERVICE]: Refusing request for {0} from client {1}", // e.RequestedAssetID, m_client.AgentId); - + return; } - else if (!missingTextureLimitStrategy.AllowRequest(e.RequestedAssetID)) + else if (!missingTextureLimitStrategy.AllowRequest(e.RequestedAssetID)) { if (missingTextureLimitStrategy.IsFirstRefusal(e.RequestedAssetID)) { @@ -135,17 +132,17 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureDownload // m_log.DebugFormat( // "[USER TEXTURE DOWNLOAD SERVICE]: Dropping requests for notified missing texture {0} for client {1} since we have received more than {2} requests", // e.RequestedAssetID, m_client.AgentId, MAX_ALLOWED_TEXTURE_REQUESTS); - } - - return; + } + + return; } - + m_scene.AddPendingDownloads(1); - - TextureSender.TextureSender requestHandler = new TextureSender.TextureSender(m_client, e.DiscardLevel, e.PacketNumber); + + TextureSender.TextureSender requestHandler = new TextureSender.TextureSender(m_client, e.DiscardLevel, e.PacketNumber); m_textureSenders.Add(e.RequestedAssetID, requestHandler); - - m_scene.AssetCache.GetAsset(e.RequestedAssetID, TextureCallback, true); + + m_scene.AssetCache.GetAsset(e.RequestedAssetID, TextureCallback, true); } } } @@ -170,7 +167,7 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureDownload public void TextureCallback(LLUUID textureID, AssetBase texture) { //m_log.DebugFormat("[USER TEXTURE DOWNLOAD SERVICE]: Calling TextureCallback with {0}, texture == null is {1}", textureID, (texture == null ? true : false)); - + lock (m_textureSenders) { TextureSender.TextureSender textureSender; @@ -181,18 +178,18 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureDownload // this on to the TextureSender it will blow up, so just discard for now. // Needs investigation. if (texture == null || texture.Data == null) - { + { if (!missingTextureLimitStrategy.IsMonitoringRequests(textureID)) { missingTextureLimitStrategy.MonitorRequests(textureID); m_log.DebugFormat( - "[USER TEXTURE DOWNLOAD SERVICE]: Queueing first TextureNotFoundSender for {0}, client {1}", + "[USER TEXTURE DOWNLOAD SERVICE]: Queueing first TextureNotFoundSender for {0}, client {1}", textureID, m_client.AgentId); } - + ITextureSender textureNotFoundSender = new TextureNotFoundSender(m_client, textureID); - EnqueueTextureSender(textureNotFoundSender); + EnqueueTextureSender(textureNotFoundSender); } else { @@ -200,13 +197,13 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureDownload { textureSender.TextureReceived(texture); EnqueueTextureSender(textureSender); - + foundTextureLimitStrategy.MonitorRequests(textureID); } } //m_log.InfoFormat("[TEXTURE SENDER] Removing texture sender with uuid {0}", textureID); - m_textureSenders.Remove(textureID); + m_textureSenders.Remove(textureID); //m_log.InfoFormat("[TEXTURE SENDER] Current texture senders in dictionary: {0}", m_textureSenders.Count); } else @@ -240,7 +237,7 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureDownload { lock (m_textureSenders) { - foreach( TextureSender.TextureSender textureSender in m_textureSenders.Values ) + foreach (TextureSender.TextureSender textureSender in m_textureSenders.Values) { textureSender.Cancel = true; } -- cgit v1.1