aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Modules/Agent/TextureDownload
diff options
context:
space:
mode:
authorJeff Ames2008-05-01 14:31:30 +0000
committerJeff Ames2008-05-01 14:31:30 +0000
commitd51ce47b2d7635b17f3dd429158e8f59b78b83aa (patch)
treed3595bd5194199184059aa398b91a51dc6c799cf /OpenSim/Region/Environment/Modules/Agent/TextureDownload
parent* Looks like I had the bamboo build right in the first place - it was just th... (diff)
downloadopensim-SC_OLD-d51ce47b2d7635b17f3dd429158e8f59b78b83aa.zip
opensim-SC_OLD-d51ce47b2d7635b17f3dd429158e8f59b78b83aa.tar.gz
opensim-SC_OLD-d51ce47b2d7635b17f3dd429158e8f59b78b83aa.tar.bz2
opensim-SC_OLD-d51ce47b2d7635b17f3dd429158e8f59b78b83aa.tar.xz
Update svn properties. Minor formatting cleanup.
Diffstat (limited to 'OpenSim/Region/Environment/Modules/Agent/TextureDownload')
-rw-r--r--OpenSim/Region/Environment/Modules/Agent/TextureDownload/TextureDownloadModule.cs436
-rw-r--r--OpenSim/Region/Environment/Modules/Agent/TextureDownload/TextureNotFoundSender.cs194
-rw-r--r--OpenSim/Region/Environment/Modules/Agent/TextureDownload/UserTextureDownloadService.cs496
3 files changed, 563 insertions, 563 deletions
diff --git a/OpenSim/Region/Environment/Modules/Agent/TextureDownload/TextureDownloadModule.cs b/OpenSim/Region/Environment/Modules/Agent/TextureDownload/TextureDownloadModule.cs
index ae2df69..474ac75 100644
--- a/OpenSim/Region/Environment/Modules/Agent/TextureDownload/TextureDownloadModule.cs
+++ b/OpenSim/Region/Environment/Modules/Agent/TextureDownload/TextureDownloadModule.cs
@@ -1,219 +1,219 @@
1/* 1/*
2 * Copyright (c) Contributors, http://opensimulator.org/ 2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders. 3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met: 6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright 7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright 9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution. 11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSim Project nor the 12 * * Neither the name of the OpenSim Project nor the
13 * names of its contributors may be used to endorse or promote products 13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission. 14 * derived from this software without specific prior written permission.
15 * 15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY 16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Threading; 30using System.Threading;
31using libsecondlife; 31using libsecondlife;
32using Nini.Config; 32using Nini.Config;
33using OpenSim.Framework; 33using OpenSim.Framework;
34using OpenSim.Region.Environment.Interfaces; 34using OpenSim.Region.Environment.Interfaces;
35using OpenSim.Region.Environment.Scenes; 35using OpenSim.Region.Environment.Scenes;
36 36
37namespace OpenSim.Region.Environment.Modules.Agent.TextureDownload 37namespace OpenSim.Region.Environment.Modules.Agent.TextureDownload
38{ 38{
39 public class TextureDownloadModule : IRegionModule 39 public class TextureDownloadModule : IRegionModule
40 { 40 {
41 //private static readonly log4net.ILog m_log 41 //private static readonly log4net.ILog m_log
42 // = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); 42 // = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
43 43
44 /// <summary> 44 /// <summary>
45 /// There is one queue for all textures waiting to be sent, regardless of the requesting user. 45 /// There is one queue for all textures waiting to be sent, regardless of the requesting user.
46 /// </summary> 46 /// </summary>
47 private readonly BlockingQueue<ITextureSender> m_queueSenders 47 private readonly BlockingQueue<ITextureSender> m_queueSenders
48 = new BlockingQueue<ITextureSender>(); 48 = new BlockingQueue<ITextureSender>();
49 49
50 /// <summary> 50 /// <summary>
51 /// Each user has their own texture download service. 51 /// Each user has their own texture download service.
52 /// </summary> 52 /// </summary>
53 private readonly Dictionary<LLUUID, UserTextureDownloadService> m_userTextureServices = 53 private readonly Dictionary<LLUUID, UserTextureDownloadService> m_userTextureServices =
54 new Dictionary<LLUUID, UserTextureDownloadService>(); 54 new Dictionary<LLUUID, UserTextureDownloadService>();
55 55
56 private Scene m_scene; 56 private Scene m_scene;
57 private List<Scene> m_scenes = new List<Scene>(); 57 private List<Scene> m_scenes = new List<Scene>();
58 58
59 private Thread m_thread; 59 private Thread m_thread;
60 60
61 public TextureDownloadModule() 61 public TextureDownloadModule()
62 { 62 {
63 } 63 }
64 64
65 #region IRegionModule Members 65 #region IRegionModule Members
66 66
67 public void Initialise(Scene scene, IConfigSource config) 67 public void Initialise(Scene scene, IConfigSource config)
68 { 68 {
69 if (m_scene == null) 69 if (m_scene == null)
70 { 70 {
71 //Console.WriteLine("Creating Texture download module"); 71 //Console.WriteLine("Creating Texture download module");
72 m_thread = new Thread(new ThreadStart(ProcessTextureSenders)); 72 m_thread = new Thread(new ThreadStart(ProcessTextureSenders));
73 m_thread.Name = "ProcessTextureSenderThread"; 73 m_thread.Name = "ProcessTextureSenderThread";
74 m_thread.IsBackground = true; 74 m_thread.IsBackground = true;
75 m_thread.Start(); 75 m_thread.Start();
76 ThreadTracker.Add(m_thread); 76 ThreadTracker.Add(m_thread);
77 } 77 }
78 78
79 if (!m_scenes.Contains(scene)) 79 if (!m_scenes.Contains(scene))
80 { 80 {
81 m_scenes.Add(scene); 81 m_scenes.Add(scene);
82 m_scene = scene; 82 m_scene = scene;
83 m_scene.EventManager.OnNewClient += NewClient; 83 m_scene.EventManager.OnNewClient += NewClient;
84 m_scene.EventManager.OnRemovePresence += EventManager_OnRemovePresence; 84 m_scene.EventManager.OnRemovePresence += EventManager_OnRemovePresence;
85 } 85 }
86 } 86 }
87 87
88 public void PostInitialise() 88 public void PostInitialise()
89 { 89 {
90 } 90 }
91 91
92 public void Close() 92 public void Close()
93 { 93 {
94 } 94 }
95 95
96 public string Name 96 public string Name
97 { 97 {
98 get { return "TextureDownloadModule"; } 98 get { return "TextureDownloadModule"; }
99 } 99 }
100 100
101 public bool IsSharedModule 101 public bool IsSharedModule
102 { 102 {
103 get { return false; } 103 get { return false; }
104 } 104 }
105 105
106 #endregion 106 #endregion
107 107
108 /// <summary> 108 /// <summary>
109 /// Cleanup the texture service related objects for the removed presence. 109 /// Cleanup the texture service related objects for the removed presence.
110 /// </summary> 110 /// </summary>
111 /// <param name="agentId"> </param> 111 /// <param name="agentId"> </param>
112 private void EventManager_OnRemovePresence(LLUUID agentId) 112 private void EventManager_OnRemovePresence(LLUUID agentId)
113 { 113 {
114 UserTextureDownloadService textureService; 114 UserTextureDownloadService textureService;
115 115
116 lock (m_userTextureServices) 116 lock (m_userTextureServices)
117 { 117 {
118 if (m_userTextureServices.TryGetValue(agentId, out textureService)) 118 if (m_userTextureServices.TryGetValue(agentId, out textureService))
119 { 119 {
120 textureService.Close(); 120 textureService.Close();
121 121
122 m_userTextureServices.Remove(agentId); 122 m_userTextureServices.Remove(agentId);
123 } 123 }
124 } 124 }
125 } 125 }
126 126
127 public void NewClient(IClientAPI client) 127 public void NewClient(IClientAPI client)
128 { 128 {
129 client.OnRequestTexture += TextureRequest; 129 client.OnRequestTexture += TextureRequest;
130 } 130 }
131 131
132 /// <summary> 132 /// <summary>
133 /// Does this user have a registered texture download service? 133 /// Does this user have a registered texture download service?
134 /// </summary> 134 /// </summary>
135 /// <param name="userID"></param> 135 /// <param name="userID"></param>
136 /// <param name="textureService"></param> 136 /// <param name="textureService"></param>
137 /// <returns>Always returns true, since a service is created if one does not already exist</returns> 137 /// <returns>Always returns true, since a service is created if one does not already exist</returns>
138 private bool TryGetUserTextureService( 138 private bool TryGetUserTextureService(
139 IClientAPI client, out UserTextureDownloadService textureService) 139 IClientAPI client, out UserTextureDownloadService textureService)
140 { 140 {
141 lock (m_userTextureServices) 141 lock (m_userTextureServices)
142 { 142 {
143 if (m_userTextureServices.TryGetValue(client.AgentId, out textureService)) 143 if (m_userTextureServices.TryGetValue(client.AgentId, out textureService))
144 { 144 {
145 return true; 145 return true;
146 } 146 }
147 147
148 textureService = new UserTextureDownloadService(client, m_scene, m_queueSenders); 148 textureService = new UserTextureDownloadService(client, m_scene, m_queueSenders);
149 m_userTextureServices.Add(client.AgentId, textureService); 149 m_userTextureServices.Add(client.AgentId, textureService);
150 150
151 return true; 151 return true;
152 } 152 }
153 } 153 }
154 154
155 /// <summary> 155 /// <summary>
156 /// Start the process of requesting a given texture. 156 /// Start the process of requesting a given texture.
157 /// </summary> 157 /// </summary>
158 /// <param name="sender"> </param> 158 /// <param name="sender"> </param>
159 /// <param name="e"></param> 159 /// <param name="e"></param>
160 public void TextureRequest(Object sender, TextureRequestArgs e) 160 public void TextureRequest(Object sender, TextureRequestArgs e)
161 { 161 {
162 IClientAPI client = (IClientAPI) sender; 162 IClientAPI client = (IClientAPI) sender;
163 UserTextureDownloadService textureService; 163 UserTextureDownloadService textureService;
164 164
165 if (TryGetUserTextureService(client, out textureService)) 165 if (TryGetUserTextureService(client, out textureService))
166 { 166 {
167 textureService.HandleTextureRequest(e); 167 textureService.HandleTextureRequest(e);
168 } 168 }
169 } 169 }
170 170
171 /// <summary> 171 /// <summary>
172 /// Entry point for the thread dedicated to processing the texture queue. 172 /// Entry point for the thread dedicated to processing the texture queue.
173 /// </summary> 173 /// </summary>
174 public void ProcessTextureSenders() 174 public void ProcessTextureSenders()
175 { 175 {
176 ITextureSender sender = null; 176 ITextureSender sender = null;
177 177
178 while (true) 178 while (true)
179 { 179 {
180 sender = m_queueSenders.Dequeue(); 180 sender = m_queueSenders.Dequeue();
181 181
182 if (sender.Cancel) 182 if (sender.Cancel)
183 { 183 {
184 TextureSent(sender); 184 TextureSent(sender);
185 185
186 sender.Cancel = false; 186 sender.Cancel = false;
187 } 187 }
188 else 188 else
189 { 189 {
190 bool finished = sender.SendTexturePacket(); 190 bool finished = sender.SendTexturePacket();
191 if (finished) 191 if (finished)
192 { 192 {
193 TextureSent(sender); 193 TextureSent(sender);
194 } 194 }
195 else 195 else
196 { 196 {
197 m_queueSenders.Enqueue(sender); 197 m_queueSenders.Enqueue(sender);
198 } 198 }
199 } 199 }
200 200
201 // Make sure that any sender we currently have can get garbage collected 201 // Make sure that any sender we currently have can get garbage collected
202 sender = null; 202 sender = null;
203 203
204 //m_log.InfoFormat("[TEXTURE DOWNLOAD] Texture sender queue size: {0}", m_queueSenders.Count()); 204 //m_log.InfoFormat("[TEXTURE DOWNLOAD] Texture sender queue size: {0}", m_queueSenders.Count());
205 } 205 }
206 } 206 }
207 207
208 /// <summary> 208 /// <summary>
209 /// Called when the texture has finished sending. 209 /// Called when the texture has finished sending.
210 /// </summary> 210 /// </summary>
211 /// <param name="sender"></param> 211 /// <param name="sender"></param>
212 private void TextureSent(ITextureSender sender) 212 private void TextureSent(ITextureSender sender)
213 { 213 {
214 sender.Sending = false; 214 sender.Sending = false;
215 //m_log.DebugFormat("[TEXTURE DOWNLOAD]: Removing download stat for {0}", sender.assetID); 215 //m_log.DebugFormat("[TEXTURE DOWNLOAD]: Removing download stat for {0}", sender.assetID);
216 m_scene.AddPendingDownloads(-1); 216 m_scene.AddPendingDownloads(-1);
217 } 217 }
218 } 218 }
219} \ No newline at end of file 219} \ 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 b181d20..70e44d4 100644
--- a/OpenSim/Region/Environment/Modules/Agent/TextureDownload/TextureNotFoundSender.cs
+++ b/OpenSim/Region/Environment/Modules/Agent/TextureDownload/TextureNotFoundSender.cs
@@ -1,98 +1,98 @@
1/* 1/*
2 * Copyright (c) Contributors, http://opensimulator.org/ 2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders. 3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met: 6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright 7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright 9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution. 11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSim Project nor the 12 * * Neither the name of the OpenSim Project nor the
13 * names of its contributors may be used to endorse or promote products 13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission. 14 * derived from this software without specific prior written permission.
15 * 15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY 16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28using libsecondlife; 28using libsecondlife;
29using libsecondlife.Packets; 29using libsecondlife.Packets;
30using OpenSim.Framework; 30using OpenSim.Framework;
31using OpenSim.Region.Environment.Interfaces; 31using OpenSim.Region.Environment.Interfaces;
32 32
33namespace OpenSim.Region.Environment.Modules.Agent.TextureDownload 33namespace OpenSim.Region.Environment.Modules.Agent.TextureDownload
34{ 34{
35 /// <summary> 35 /// <summary>
36 /// Sends a 'texture not found' packet back to the client 36 /// Sends a 'texture not found' packet back to the client
37 /// </summary> 37 /// </summary>
38 public class TextureNotFoundSender : ITextureSender 38 public class TextureNotFoundSender : ITextureSender
39 { 39 {
40 //private static readonly log4net.ILog m_log 40 //private static readonly log4net.ILog m_log
41 // = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); 41 // = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
42 42
43 private bool m_cancel = false; 43 private bool m_cancel = false;
44 private IClientAPI m_client; 44 private IClientAPI m_client;
45 45
46 // See ITextureSender 46 // See ITextureSender
47 47
48 private bool m_sending = false; 48 private bool m_sending = false;
49 private LLUUID m_textureId; 49 private LLUUID m_textureId;
50 50
51 // See ITextureSender 51 // See ITextureSender
52 52
53 public TextureNotFoundSender(IClientAPI client, LLUUID textureID) 53 public TextureNotFoundSender(IClientAPI client, LLUUID textureID)
54 { 54 {
55 m_client = client; 55 m_client = client;
56 m_textureId = textureID; 56 m_textureId = textureID;
57 } 57 }
58 58
59 #region ITextureSender Members 59 #region ITextureSender Members
60 60
61 public bool Sending 61 public bool Sending
62 { 62 {
63 get { return false; } 63 get { return false; }
64 set { m_sending = value; } 64 set { m_sending = value; }
65 } 65 }
66 66
67 public bool Cancel 67 public bool Cancel
68 { 68 {
69 get { return false; } 69 get { return false; }
70 set { m_cancel = value; } 70 set { m_cancel = value; }
71 } 71 }
72 72
73 // See ITextureSender 73 // See ITextureSender
74 public void UpdateRequest(int discardLevel, uint packetNumber) 74 public void UpdateRequest(int discardLevel, uint packetNumber)
75 { 75 {
76 // Not need to implement since priority changes don't affect this operation 76 // Not need to implement since priority changes don't affect this operation
77 } 77 }
78 78
79 // See ITextureSender 79 // See ITextureSender
80 public bool SendTexturePacket() 80 public bool SendTexturePacket()
81 { 81 {
82 //m_log.InfoFormat( 82 //m_log.InfoFormat(
83 // "[TEXTURE NOT FOUND SENDER]: Informing the client that texture {0} cannot be found", 83 // "[TEXTURE NOT FOUND SENDER]: Informing the client that texture {0} cannot be found",
84 // m_textureId); 84 // m_textureId);
85 85
86 ImageNotInDatabasePacket notFound = new ImageNotInDatabasePacket(); 86 ImageNotInDatabasePacket notFound = new ImageNotInDatabasePacket();
87 notFound.ImageID.ID = m_textureId; 87 notFound.ImageID.ID = m_textureId;
88 88
89 // XXX Temporarily disabling as this appears to be causing client crashes on at least 89 // XXX Temporarily disabling as this appears to be causing client crashes on at least
90 // 1.19.0(5) of the Linden Second Life client. 90 // 1.19.0(5) of the Linden Second Life client.
91 // m_client.OutPacket(notFound, ThrottleOutPacketType.Texture); 91 // m_client.OutPacket(notFound, ThrottleOutPacketType.Texture);
92 92
93 return true; 93 return true;
94 } 94 }
95 95
96 #endregion 96 #endregion
97 } 97 }
98} \ No newline at end of file 98} \ 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 4f63fd0..a450cdc 100644
--- a/OpenSim/Region/Environment/Modules/Agent/TextureDownload/UserTextureDownloadService.cs
+++ b/OpenSim/Region/Environment/Modules/Agent/TextureDownload/UserTextureDownloadService.cs
@@ -1,249 +1,249 @@
1/* 1/*
2 * Copyright (c) Contributors, http://opensimulator.org/ 2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders. 3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met: 6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright 7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright 9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution. 11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSim Project nor the 12 * * Neither the name of the OpenSim Project nor the
13 * names of its contributors may be used to endorse or promote products 13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission. 14 * derived from this software without specific prior written permission.
15 * 15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY 16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28using System.Collections.Generic; 28using System.Collections.Generic;
29using System.Reflection; 29using System.Reflection;
30using libsecondlife; 30using libsecondlife;
31using log4net; 31using log4net;
32using OpenSim.Framework; 32using OpenSim.Framework;
33using OpenSim.Framework.Communications.Limit; 33using OpenSim.Framework.Communications.Limit;
34using OpenSim.Region.Environment.Interfaces; 34using OpenSim.Region.Environment.Interfaces;
35using OpenSim.Region.Environment.Scenes; 35using OpenSim.Region.Environment.Scenes;
36 36
37namespace OpenSim.Region.Environment.Modules.Agent.TextureDownload 37namespace OpenSim.Region.Environment.Modules.Agent.TextureDownload
38{ 38{
39 /// <summary> 39 /// <summary>
40 /// This module sets up texture senders in response to client texture requests, and places them on a 40 /// This module sets up texture senders in response to client texture requests, and places them on a
41 /// processing queue once those senders have the appropriate data (i.e. a texture retrieved from the 41 /// processing queue once those senders have the appropriate data (i.e. a texture retrieved from the
42 /// asset cache). 42 /// asset cache).
43 /// </summary> 43 /// </summary>
44 public class UserTextureDownloadService 44 public class UserTextureDownloadService
45 { 45 {
46 private static readonly ILog m_log 46 private static readonly ILog m_log
47 = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 47 = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
48 48
49 /// <summary> 49 /// <summary>
50 /// We will allow the client to request the same texture n times before dropping further requests 50 /// We will allow the client to request the same texture n times before dropping further requests
51 /// 51 ///
52 /// This number includes repeated requests for the same texture at different resolutions (which we don't 52 /// This number includes repeated requests for the same texture at different resolutions (which we don't
53 /// currently handle properly as far as I know). However, this situation should be handled in a more 53 /// currently handle properly as far as I know). However, this situation should be handled in a more
54 /// sophisticated way. 54 /// sophisticated way.
55 /// </summary> 55 /// </summary>
56 private static readonly int MAX_ALLOWED_TEXTURE_REQUESTS = 5; 56 private static readonly int MAX_ALLOWED_TEXTURE_REQUESTS = 5;
57 57
58 /// <summary> 58 /// <summary>
59 /// XXX Also going to limit requests for found textures. 59 /// XXX Also going to limit requests for found textures.
60 /// </summary> 60 /// </summary>
61 private readonly IRequestLimitStrategy<LLUUID> foundTextureLimitStrategy 61 private readonly IRequestLimitStrategy<LLUUID> foundTextureLimitStrategy
62 = new RepeatLimitStrategy<LLUUID>(MAX_ALLOWED_TEXTURE_REQUESTS); 62 = new RepeatLimitStrategy<LLUUID>(MAX_ALLOWED_TEXTURE_REQUESTS);
63 63
64 private readonly IClientAPI m_client; 64 private readonly IClientAPI m_client;
65 private readonly Scene m_scene; 65 private readonly Scene m_scene;
66 66
67 /// <summary> 67 /// <summary>
68 /// 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
69 /// cache. Another module actually invokes the send. 69 /// cache. Another module actually invokes the send.
70 /// </summary> 70 /// </summary>
71 private readonly BlockingQueue<ITextureSender> m_sharedSendersQueue; 71 private readonly BlockingQueue<ITextureSender> m_sharedSendersQueue;
72 72
73 /// <summary> 73 /// <summary>
74 /// Holds texture senders before they have received the appropriate texture from the asset cache. 74 /// Holds texture senders before they have received the appropriate texture from the asset cache.
75 /// </summary> 75 /// </summary>
76 private readonly Dictionary<LLUUID, TextureSender.TextureSender> m_textureSenders = new Dictionary<LLUUID, TextureSender.TextureSender>(); 76 private readonly Dictionary<LLUUID, TextureSender.TextureSender> m_textureSenders = new Dictionary<LLUUID, TextureSender.TextureSender>();
77 77
78 /// <summary> 78 /// <summary>
79 /// We're going to limit requests for the same missing texture. 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 80 /// XXX This is really a temporary solution to deal with the situation where a client continually requests
81 /// the same missing textures 81 /// the same missing textures
82 /// </summary> 82 /// </summary>
83 private readonly IRequestLimitStrategy<LLUUID> missingTextureLimitStrategy 83 private readonly IRequestLimitStrategy<LLUUID> missingTextureLimitStrategy
84 = new RepeatLimitStrategy<LLUUID>(MAX_ALLOWED_TEXTURE_REQUESTS); 84 = new RepeatLimitStrategy<LLUUID>(MAX_ALLOWED_TEXTURE_REQUESTS);
85 85
86 public UserTextureDownloadService( 86 public UserTextureDownloadService(
87 IClientAPI client, Scene scene, BlockingQueue<ITextureSender> sharedQueue) 87 IClientAPI client, Scene scene, BlockingQueue<ITextureSender> sharedQueue)
88 { 88 {
89 m_client = client; 89 m_client = client;
90 m_scene = scene; 90 m_scene = scene;
91 m_sharedSendersQueue = sharedQueue; 91 m_sharedSendersQueue = sharedQueue;
92 } 92 }
93 93
94 /// <summary> 94 /// <summary>
95 /// Handle a texture request. This involves creating a texture sender and placing it on the 95 /// Handle a texture request. This involves creating a texture sender and placing it on the
96 /// previously passed in shared queue. 96 /// previously passed in shared queue.
97 /// </summary> 97 /// </summary>
98 /// <param name="e"></param> 98 /// <param name="e"></param>
99 public void HandleTextureRequest(TextureRequestArgs e) 99 public void HandleTextureRequest(TextureRequestArgs e)
100 { 100 {
101 TextureSender.TextureSender textureSender; 101 TextureSender.TextureSender textureSender;
102 102
103 //TODO: should be working out the data size/ number of packets to be sent for each discard level 103 //TODO: should be working out the data size/ number of packets to be sent for each discard level
104 if ((e.DiscardLevel >= 0) || (e.Priority != 0)) 104 if ((e.DiscardLevel >= 0) || (e.Priority != 0))
105 { 105 {
106 lock (m_textureSenders) 106 lock (m_textureSenders)
107 { 107 {
108 if (m_textureSenders.TryGetValue(e.RequestedAssetID, out textureSender)) 108 if (m_textureSenders.TryGetValue(e.RequestedAssetID, out textureSender))
109 { 109 {
110 // 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
111 // yet, then update the request accordingly. 111 // yet, then update the request accordingly.
112 textureSender.UpdateRequest(e.DiscardLevel, e.PacketNumber); 112 textureSender.UpdateRequest(e.DiscardLevel, e.PacketNumber);
113 } 113 }
114 else 114 else
115 { 115 {
116 if (!foundTextureLimitStrategy.AllowRequest(e.RequestedAssetID)) 116 if (!foundTextureLimitStrategy.AllowRequest(e.RequestedAssetID))
117 { 117 {
118// m_log.DebugFormat( 118// m_log.DebugFormat(
119// "[USER TEXTURE DOWNLOAD SERVICE]: Refusing request for {0} from client {1}", 119// "[USER TEXTURE DOWNLOAD SERVICE]: Refusing request for {0} from client {1}",
120// e.RequestedAssetID, m_client.AgentId); 120// e.RequestedAssetID, m_client.AgentId);
121 121
122 return; 122 return;
123 } 123 }
124 else if (!missingTextureLimitStrategy.AllowRequest(e.RequestedAssetID)) 124 else if (!missingTextureLimitStrategy.AllowRequest(e.RequestedAssetID))
125 { 125 {
126 if (missingTextureLimitStrategy.IsFirstRefusal(e.RequestedAssetID)) 126 if (missingTextureLimitStrategy.IsFirstRefusal(e.RequestedAssetID))
127 { 127 {
128 // Commenting out this message for now as it causes too much noise with other 128 // Commenting out this message for now as it causes too much noise with other
129 // debug messages. 129 // debug messages.
130 // TODO: possibly record this as a statistic in the future 130 // TODO: possibly record this as a statistic in the future
131 // 131 //
132// m_log.DebugFormat( 132// m_log.DebugFormat(
133// "[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",
134// e.RequestedAssetID, m_client.AgentId, MAX_ALLOWED_TEXTURE_REQUESTS); 134// e.RequestedAssetID, m_client.AgentId, MAX_ALLOWED_TEXTURE_REQUESTS);
135 } 135 }
136 136
137 return; 137 return;
138 } 138 }
139 139
140 m_scene.AddPendingDownloads(1); 140 m_scene.AddPendingDownloads(1);
141 141
142 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);
143 m_textureSenders.Add(e.RequestedAssetID, requestHandler); 143 m_textureSenders.Add(e.RequestedAssetID, requestHandler);
144 144
145 m_scene.AssetCache.GetAsset(e.RequestedAssetID, TextureCallback, true); 145 m_scene.AssetCache.GetAsset(e.RequestedAssetID, TextureCallback, true);
146 } 146 }
147 } 147 }
148 } 148 }
149 else 149 else
150 { 150 {
151 lock (m_textureSenders) 151 lock (m_textureSenders)
152 { 152 {
153 if (m_textureSenders.TryGetValue(e.RequestedAssetID, out textureSender)) 153 if (m_textureSenders.TryGetValue(e.RequestedAssetID, out textureSender))
154 { 154 {
155 textureSender.Cancel = true; 155 textureSender.Cancel = true;
156 } 156 }
157 } 157 }
158 } 158 }
159 } 159 }
160 160
161 /// <summary> 161 /// <summary>
162 /// The callback for the asset cache when a texture has been retrieved. This method queues the 162 /// The callback for the asset cache when a texture has been retrieved. This method queues the
163 /// texture sender for processing. 163 /// texture sender for processing.
164 /// </summary> 164 /// </summary>
165 /// <param name="textureID"></param> 165 /// <param name="textureID"></param>
166 /// <param name="texture"></param> 166 /// <param name="texture"></param>
167 public void TextureCallback(LLUUID textureID, AssetBase texture) 167 public void TextureCallback(LLUUID textureID, AssetBase texture)
168 { 168 {
169 //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));
170 170
171 lock (m_textureSenders) 171 lock (m_textureSenders)
172 { 172 {
173 TextureSender.TextureSender textureSender; 173 TextureSender.TextureSender textureSender;
174 174
175 if (m_textureSenders.TryGetValue(textureID, out textureSender)) 175 if (m_textureSenders.TryGetValue(textureID, out textureSender))
176 { 176 {
177 // XXX It may be perfectly valid for a texture to have no data... but if we pass 177 // XXX It may be perfectly valid for a texture to have no data... but if we pass
178 // 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.
179 // Needs investigation. 179 // Needs investigation.
180 if (texture == null || texture.Data == null) 180 if (texture == null || texture.Data == null)
181 { 181 {
182 if (!missingTextureLimitStrategy.IsMonitoringRequests(textureID)) 182 if (!missingTextureLimitStrategy.IsMonitoringRequests(textureID))
183 { 183 {
184 missingTextureLimitStrategy.MonitorRequests(textureID); 184 missingTextureLimitStrategy.MonitorRequests(textureID);
185 185
186 m_log.DebugFormat( 186 m_log.DebugFormat(
187 "[USER TEXTURE DOWNLOAD SERVICE]: Queueing first TextureNotFoundSender for {0}, client {1}", 187 "[USER TEXTURE DOWNLOAD SERVICE]: Queueing first TextureNotFoundSender for {0}, client {1}",
188 textureID, m_client.AgentId); 188 textureID, m_client.AgentId);
189 } 189 }
190 190
191 ITextureSender textureNotFoundSender = new TextureNotFoundSender(m_client, textureID); 191 ITextureSender textureNotFoundSender = new TextureNotFoundSender(m_client, textureID);
192 EnqueueTextureSender(textureNotFoundSender); 192 EnqueueTextureSender(textureNotFoundSender);
193 } 193 }
194 else 194 else
195 { 195 {
196 if (!textureSender.ImageLoaded) 196 if (!textureSender.ImageLoaded)
197 { 197 {
198 textureSender.TextureReceived(texture); 198 textureSender.TextureReceived(texture);
199 EnqueueTextureSender(textureSender); 199 EnqueueTextureSender(textureSender);
200 200
201 foundTextureLimitStrategy.MonitorRequests(textureID); 201 foundTextureLimitStrategy.MonitorRequests(textureID);
202 } 202 }
203 } 203 }
204 204
205 //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);
206 m_textureSenders.Remove(textureID); 206 m_textureSenders.Remove(textureID);
207 //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);
208 } 208 }
209 else 209 else
210 { 210 {
211 m_log.WarnFormat( 211 m_log.WarnFormat(
212 "Got a texture uuid {0} with no sender object to handle it, this shouldn't happen", 212 "Got a texture uuid {0} with no sender object to handle it, this shouldn't happen",
213 textureID); 213 textureID);
214 } 214 }
215 } 215 }
216 } 216 }
217 217
218 /// <summary> 218 /// <summary>
219 /// Place a ready texture sender on the processing queue. 219 /// Place a ready texture sender on the processing queue.
220 /// </summary> 220 /// </summary>
221 /// <param name="textureSender"></param> 221 /// <param name="textureSender"></param>
222 private void EnqueueTextureSender(ITextureSender textureSender) 222 private void EnqueueTextureSender(ITextureSender textureSender)
223 { 223 {
224 textureSender.Cancel = false; 224 textureSender.Cancel = false;
225 textureSender.Sending = true; 225 textureSender.Sending = true;
226 226
227 if (!m_sharedSendersQueue.Contains(textureSender)) 227 if (!m_sharedSendersQueue.Contains(textureSender))
228 { 228 {
229 m_sharedSendersQueue.Enqueue(textureSender); 229 m_sharedSendersQueue.Enqueue(textureSender);
230 } 230 }
231 } 231 }
232 232
233 /// <summary> 233 /// <summary>
234 /// Close this module. 234 /// Close this module.
235 /// </summary> 235 /// </summary>
236 internal void Close() 236 internal void Close()
237 { 237 {
238 lock (m_textureSenders) 238 lock (m_textureSenders)
239 { 239 {
240 foreach (TextureSender.TextureSender textureSender in m_textureSenders.Values) 240 foreach (TextureSender.TextureSender textureSender in m_textureSenders.Values)
241 { 241 {
242 textureSender.Cancel = true; 242 textureSender.Cancel = true;
243 } 243 }
244 244
245 m_textureSenders.Clear(); 245 m_textureSenders.Clear();
246 } 246 }
247 } 247 }
248 } 248 }
249} \ No newline at end of file 249} \ No newline at end of file