diff options
author | Adam Frisby | 2008-04-30 21:43:47 +0000 |
---|---|---|
committer | Adam Frisby | 2008-04-30 21:43:47 +0000 |
commit | be20f41637b6c06ce3ab16bc25851b6e43468e12 (patch) | |
tree | c41081329891f4c24de704fc760fb9012954ac9d /OpenSim/Region/Environment/Modules/Agent/TextureDownload/UserTextureDownloadService.cs | |
parent | * Sometimes you know, you do something really stupid. (diff) | |
download | opensim-SC-be20f41637b6c06ce3ab16bc25851b6e43468e12.zip opensim-SC-be20f41637b6c06ce3ab16bc25851b6e43468e12.tar.gz opensim-SC-be20f41637b6c06ce3ab16bc25851b6e43468e12.tar.bz2 opensim-SC-be20f41637b6c06ce3ab16bc25851b6e43468e12.tar.xz |
* Cruft removal step #1. Cleaning Modules directory.
Diffstat (limited to 'OpenSim/Region/Environment/Modules/Agent/TextureDownload/UserTextureDownloadService.cs')
-rw-r--r-- | OpenSim/Region/Environment/Modules/Agent/TextureDownload/UserTextureDownloadService.cs | 85 |
1 files changed, 41 insertions, 44 deletions
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; | |||
32 | using OpenSim.Framework; | 32 | using OpenSim.Framework; |
33 | using OpenSim.Framework.Communications.Limit; | 33 | using OpenSim.Framework.Communications.Limit; |
34 | using OpenSim.Region.Environment.Interfaces; | 34 | using OpenSim.Region.Environment.Interfaces; |
35 | using OpenSim.Region.Environment.Modules.Agent.TextureDownload; | ||
36 | using OpenSim.Region.Environment.Modules.Agent.TextureSender; | ||
37 | using OpenSim.Region.Environment.Scenes; | 35 | using OpenSim.Region.Environment.Scenes; |
38 | 36 | ||
39 | namespace OpenSim.Region.Environment.Modules.Agent.TextureDownload | 37 | namespace OpenSim.Region.Environment.Modules.Agent.TextureDownload |
@@ -45,7 +43,7 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureDownload | |||
45 | /// </summary> | 43 | /// </summary> |
46 | public class UserTextureDownloadService | 44 | public class UserTextureDownloadService |
47 | { | 45 | { |
48 | private static readonly ILog m_log | 46 | private static readonly ILog m_log |
49 | = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 47 | = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
50 | 48 | ||
51 | /// <summary> | 49 | /// <summary> |
@@ -56,35 +54,34 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureDownload | |||
56 | /// sophisticated way. | 54 | /// sophisticated way. |
57 | /// </summary> | 55 | /// </summary> |
58 | private static readonly int MAX_ALLOWED_TEXTURE_REQUESTS = 5; | 56 | private static readonly int MAX_ALLOWED_TEXTURE_REQUESTS = 5; |
59 | 57 | ||
60 | /// <summary> | ||
61 | /// We're going to limit requests for the same missing texture. | ||
62 | /// XXX This is really a temporary solution to deal with the situation where a client continually requests | ||
63 | /// the same missing textures | ||
64 | /// </summary> | ||
65 | private readonly IRequestLimitStrategy<LLUUID> missingTextureLimitStrategy | ||
66 | = new RepeatLimitStrategy<LLUUID>(MAX_ALLOWED_TEXTURE_REQUESTS); | ||
67 | |||
68 | /// <summary> | 58 | /// <summary> |
69 | /// XXX Also going to limit requests for found textures. | 59 | /// XXX Also going to limit requests for found textures. |
70 | /// </summary> | 60 | /// </summary> |
71 | private readonly IRequestLimitStrategy<LLUUID> foundTextureLimitStrategy | 61 | private readonly IRequestLimitStrategy<LLUUID> foundTextureLimitStrategy |
72 | = new RepeatLimitStrategy<LLUUID>(MAX_ALLOWED_TEXTURE_REQUESTS); | 62 | = new RepeatLimitStrategy<LLUUID>(MAX_ALLOWED_TEXTURE_REQUESTS); |
73 | 63 | ||
74 | /// <summary> | 64 | private readonly IClientAPI m_client; |
75 | /// Holds texture senders before they have received the appropriate texture from the asset cache. | 65 | private readonly Scene m_scene; |
76 | /// </summary> | 66 | |
77 | private readonly Dictionary<LLUUID, TextureSender.TextureSender> m_textureSenders = new Dictionary<LLUUID, TextureSender.TextureSender>(); | ||
78 | |||
79 | /// <summary> | 67 | /// <summary> |
80 | /// Texture Senders are placed in this queue once they have received their texture from the asset | 68 | /// Texture Senders are placed in this queue once they have received their texture from the asset |
81 | /// cache. Another module actually invokes the send. | 69 | /// cache. Another module actually invokes the send. |
82 | /// </summary> | 70 | /// </summary> |
83 | private readonly BlockingQueue<ITextureSender> m_sharedSendersQueue; | 71 | private readonly BlockingQueue<ITextureSender> m_sharedSendersQueue; |
84 | 72 | ||
85 | private readonly Scene m_scene; | 73 | /// <summary> |
86 | 74 | /// Holds texture senders before they have received the appropriate texture from the asset cache. | |
87 | private readonly IClientAPI m_client; | 75 | /// </summary> |
76 | private readonly Dictionary<LLUUID, TextureSender.TextureSender> m_textureSenders = new Dictionary<LLUUID, TextureSender.TextureSender>(); | ||
77 | |||
78 | /// <summary> | ||
79 | /// We're going to limit requests for the same missing texture. | ||
80 | /// XXX This is really a temporary solution to deal with the situation where a client continually requests | ||
81 | /// the same missing textures | ||
82 | /// </summary> | ||
83 | private readonly IRequestLimitStrategy<LLUUID> missingTextureLimitStrategy | ||
84 | = new RepeatLimitStrategy<LLUUID>(MAX_ALLOWED_TEXTURE_REQUESTS); | ||
88 | 85 | ||
89 | public UserTextureDownloadService( | 86 | public UserTextureDownloadService( |
90 | IClientAPI client, Scene scene, BlockingQueue<ITextureSender> sharedQueue) | 87 | IClientAPI client, Scene scene, BlockingQueue<ITextureSender> sharedQueue) |
@@ -112,19 +109,19 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureDownload | |||
112 | { | 109 | { |
113 | // If we've received new non UUID information for this request and it hasn't dispatched | 110 | // If we've received new non UUID information for this request and it hasn't dispatched |
114 | // yet, then update the request accordingly. | 111 | // yet, then update the request accordingly. |
115 | textureSender.UpdateRequest(e.DiscardLevel, e.PacketNumber); | 112 | textureSender.UpdateRequest(e.DiscardLevel, e.PacketNumber); |
116 | } | 113 | } |
117 | else | 114 | else |
118 | { | 115 | { |
119 | if (!foundTextureLimitStrategy.AllowRequest(e.RequestedAssetID)) | 116 | if (!foundTextureLimitStrategy.AllowRequest(e.RequestedAssetID)) |
120 | { | 117 | { |
121 | // m_log.DebugFormat( | 118 | // m_log.DebugFormat( |
122 | // "[USER TEXTURE DOWNLOAD SERVICE]: Refusing request for {0} from client {1}", | 119 | // "[USER TEXTURE DOWNLOAD SERVICE]: Refusing request for {0} from client {1}", |
123 | // e.RequestedAssetID, m_client.AgentId); | 120 | // e.RequestedAssetID, m_client.AgentId); |
124 | 121 | ||
125 | return; | 122 | return; |
126 | } | 123 | } |
127 | else if (!missingTextureLimitStrategy.AllowRequest(e.RequestedAssetID)) | 124 | else if (!missingTextureLimitStrategy.AllowRequest(e.RequestedAssetID)) |
128 | { | 125 | { |
129 | if (missingTextureLimitStrategy.IsFirstRefusal(e.RequestedAssetID)) | 126 | if (missingTextureLimitStrategy.IsFirstRefusal(e.RequestedAssetID)) |
130 | { | 127 | { |
@@ -135,17 +132,17 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureDownload | |||
135 | // m_log.DebugFormat( | 132 | // m_log.DebugFormat( |
136 | // "[USER TEXTURE DOWNLOAD SERVICE]: Dropping requests for notified missing texture {0} for client {1} since we have received more than {2} requests", | 133 | // "[USER TEXTURE DOWNLOAD SERVICE]: Dropping requests for notified missing texture {0} for client {1} since we have received more than {2} requests", |
137 | // e.RequestedAssetID, m_client.AgentId, MAX_ALLOWED_TEXTURE_REQUESTS); | 134 | // e.RequestedAssetID, m_client.AgentId, MAX_ALLOWED_TEXTURE_REQUESTS); |
138 | } | 135 | } |
139 | 136 | ||
140 | return; | 137 | return; |
141 | } | 138 | } |
142 | 139 | ||
143 | m_scene.AddPendingDownloads(1); | 140 | m_scene.AddPendingDownloads(1); |
144 | 141 | ||
145 | TextureSender.TextureSender requestHandler = new TextureSender.TextureSender(m_client, e.DiscardLevel, e.PacketNumber); | 142 | TextureSender.TextureSender requestHandler = new TextureSender.TextureSender(m_client, e.DiscardLevel, e.PacketNumber); |
146 | m_textureSenders.Add(e.RequestedAssetID, requestHandler); | 143 | m_textureSenders.Add(e.RequestedAssetID, requestHandler); |
147 | 144 | ||
148 | m_scene.AssetCache.GetAsset(e.RequestedAssetID, TextureCallback, true); | 145 | m_scene.AssetCache.GetAsset(e.RequestedAssetID, TextureCallback, true); |
149 | } | 146 | } |
150 | } | 147 | } |
151 | } | 148 | } |
@@ -170,7 +167,7 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureDownload | |||
170 | public void TextureCallback(LLUUID textureID, AssetBase texture) | 167 | public void TextureCallback(LLUUID textureID, AssetBase texture) |
171 | { | 168 | { |
172 | //m_log.DebugFormat("[USER TEXTURE DOWNLOAD SERVICE]: Calling TextureCallback with {0}, texture == null is {1}", textureID, (texture == null ? true : false)); | 169 | //m_log.DebugFormat("[USER TEXTURE DOWNLOAD SERVICE]: Calling TextureCallback with {0}, texture == null is {1}", textureID, (texture == null ? true : false)); |
173 | 170 | ||
174 | lock (m_textureSenders) | 171 | lock (m_textureSenders) |
175 | { | 172 | { |
176 | TextureSender.TextureSender textureSender; | 173 | TextureSender.TextureSender textureSender; |
@@ -181,18 +178,18 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureDownload | |||
181 | // this on to the TextureSender it will blow up, so just discard for now. | 178 | // this on to the TextureSender it will blow up, so just discard for now. |
182 | // Needs investigation. | 179 | // Needs investigation. |
183 | if (texture == null || texture.Data == null) | 180 | if (texture == null || texture.Data == null) |
184 | { | 181 | { |
185 | if (!missingTextureLimitStrategy.IsMonitoringRequests(textureID)) | 182 | if (!missingTextureLimitStrategy.IsMonitoringRequests(textureID)) |
186 | { | 183 | { |
187 | missingTextureLimitStrategy.MonitorRequests(textureID); | 184 | missingTextureLimitStrategy.MonitorRequests(textureID); |
188 | 185 | ||
189 | m_log.DebugFormat( | 186 | m_log.DebugFormat( |
190 | "[USER TEXTURE DOWNLOAD SERVICE]: Queueing first TextureNotFoundSender for {0}, client {1}", | 187 | "[USER TEXTURE DOWNLOAD SERVICE]: Queueing first TextureNotFoundSender for {0}, client {1}", |
191 | textureID, m_client.AgentId); | 188 | textureID, m_client.AgentId); |
192 | } | 189 | } |
193 | 190 | ||
194 | ITextureSender textureNotFoundSender = new TextureNotFoundSender(m_client, textureID); | 191 | ITextureSender textureNotFoundSender = new TextureNotFoundSender(m_client, textureID); |
195 | EnqueueTextureSender(textureNotFoundSender); | 192 | EnqueueTextureSender(textureNotFoundSender); |
196 | } | 193 | } |
197 | else | 194 | else |
198 | { | 195 | { |
@@ -200,13 +197,13 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureDownload | |||
200 | { | 197 | { |
201 | textureSender.TextureReceived(texture); | 198 | textureSender.TextureReceived(texture); |
202 | EnqueueTextureSender(textureSender); | 199 | EnqueueTextureSender(textureSender); |
203 | 200 | ||
204 | foundTextureLimitStrategy.MonitorRequests(textureID); | 201 | foundTextureLimitStrategy.MonitorRequests(textureID); |
205 | } | 202 | } |
206 | } | 203 | } |
207 | 204 | ||
208 | //m_log.InfoFormat("[TEXTURE SENDER] Removing texture sender with uuid {0}", textureID); | 205 | //m_log.InfoFormat("[TEXTURE SENDER] Removing texture sender with uuid {0}", textureID); |
209 | m_textureSenders.Remove(textureID); | 206 | m_textureSenders.Remove(textureID); |
210 | //m_log.InfoFormat("[TEXTURE SENDER] Current texture senders in dictionary: {0}", m_textureSenders.Count); | 207 | //m_log.InfoFormat("[TEXTURE SENDER] Current texture senders in dictionary: {0}", m_textureSenders.Count); |
211 | } | 208 | } |
212 | else | 209 | else |
@@ -240,7 +237,7 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureDownload | |||
240 | { | 237 | { |
241 | lock (m_textureSenders) | 238 | lock (m_textureSenders) |
242 | { | 239 | { |
243 | foreach( TextureSender.TextureSender textureSender in m_textureSenders.Values ) | 240 | foreach (TextureSender.TextureSender textureSender in m_textureSenders.Values) |
244 | { | 241 | { |
245 | textureSender.Cancel = true; | 242 | textureSender.Cancel = true; |
246 | } | 243 | } |