aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--OpenSim/Framework/BlockingQueue.cs25
-rw-r--r--OpenSim/Framework/Communications/Cache/AssetCache.cs6
-rw-r--r--OpenSim/Framework/Communications/Cache/AssetServerBase.cs38
-rw-r--r--OpenSim/Framework/Communications/Cache/SQLAssetServer.cs20
-rw-r--r--OpenSim/Region/ClientStack/ClientView.cs5
-rw-r--r--OpenSim/Region/Environment/Modules/TextureDownloadModule.cs75
6 files changed, 91 insertions, 78 deletions
diff --git a/OpenSim/Framework/BlockingQueue.cs b/OpenSim/Framework/BlockingQueue.cs
index ae2a189..3ff3dac 100644
--- a/OpenSim/Framework/BlockingQueue.cs
+++ b/OpenSim/Framework/BlockingQueue.cs
@@ -32,27 +32,34 @@ namespace OpenSim.Framework
32{ 32{
33 public class BlockingQueue<T> 33 public class BlockingQueue<T>
34 { 34 {
35 private Queue<T> _queue = new Queue<T>(); 35 private readonly Queue<T> m_queue = new Queue<T>();
36 private object _queueSync = new object(); 36 private readonly object m_queueSync = new object();
37 37
38 public void Enqueue(T value) 38 public void Enqueue(T value)
39 { 39 {
40 lock (_queueSync) 40 lock (m_queueSync)
41 { 41 {
42 _queue.Enqueue(value); 42 m_queue.Enqueue(value);
43 Monitor.Pulse(_queueSync); 43 Monitor.Pulse(m_queueSync);
44 } 44 }
45 } 45 }
46 46
47 public T Dequeue() 47 public T Dequeue()
48 { 48 {
49 lock (_queueSync) 49 lock (m_queueSync)
50 { 50 {
51 if (_queue.Count < 1) 51 if (m_queue.Count < 1)
52 Monitor.Wait(_queueSync); 52 {
53 Monitor.Wait(m_queueSync);
54 }
53 55
54 return _queue.Dequeue(); 56 return m_queue.Dequeue();
55 } 57 }
56 } 58 }
59
60 public bool Contains(T item)
61 {
62 return m_queue.Contains(item);
63 }
57 } 64 }
58} \ No newline at end of file 65} \ No newline at end of file
diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs
index 664625e..bd3437b 100644
--- a/OpenSim/Framework/Communications/Cache/AssetCache.cs
+++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs
@@ -56,10 +56,10 @@ namespace OpenSim.Framework.Communications.Cache
56 56
57 public Dictionary<LLUUID, AssetRequestsList> RequestLists = new Dictionary<LLUUID, AssetRequestsList>(); 57 public Dictionary<LLUUID, AssetRequestsList> RequestLists = new Dictionary<LLUUID, AssetRequestsList>();
58 58
59 private IAssetServer m_assetServer; 59 private readonly IAssetServer m_assetServer;
60 60
61 private Thread m_assetCacheThread; 61 private readonly Thread m_assetCacheThread;
62 private LogBase m_log; 62 private readonly LogBase m_log;
63 63
64 /// <summary> 64 /// <summary>
65 /// 65 ///
diff --git a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs
index 318082b..f0ed968 100644
--- a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs
+++ b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs
@@ -37,11 +37,11 @@ namespace OpenSim.Framework.Communications.Cache
37{ 37{
38 public abstract class AssetServerBase : IAssetServer 38 public abstract class AssetServerBase : IAssetServer
39 { 39 {
40 protected IAssetReceiver _receiver; 40 protected IAssetReceiver m_receiver;
41 protected BlockingQueue<AssetRequest> _assetRequests; 41 protected BlockingQueue<AssetRequest> m_assetRequests;
42 protected Thread _localAssetServerThread; 42 protected Thread m_localAssetServerThread;
43 protected IAssetProvider m_assetProviderPlugin; 43 protected IAssetProvider m_assetProvider;
44 protected object syncLock = new object(); 44 protected object m_syncLock = new object();
45 45
46 // Temporarily hardcoded - should be a plugin 46 // Temporarily hardcoded - should be a plugin
47 protected IAssetLoader assetLoader = new AssetLoaderFileSystem(); 47 protected IAssetLoader assetLoader = new AssetLoaderFileSystem();
@@ -71,14 +71,14 @@ namespace OpenSim.Framework.Communications.Cache
71 MainLog.Instance.Verbose( 71 MainLog.Instance.Verbose(
72 "ASSET", "Asset {0} received from asset server", req.AssetID); 72 "ASSET", "Asset {0} received from asset server", req.AssetID);
73 73
74 _receiver.AssetReceived(asset, req.IsTexture); 74 m_receiver.AssetReceived(asset, req.IsTexture);
75 } 75 }
76 else 76 else
77 { 77 {
78 MainLog.Instance.Error( 78 MainLog.Instance.Error(
79 "ASSET", "Asset {0} not found by asset server", req.AssetID); 79 "ASSET", "Asset {0} not found by asset server", req.AssetID);
80 80
81 _receiver.AssetNotFound(req.AssetID); 81 m_receiver.AssetNotFound(req.AssetID);
82 } 82 }
83 } 83 }
84 84
@@ -95,11 +95,11 @@ namespace OpenSim.Framework.Communications.Cache
95 public AssetServerBase() 95 public AssetServerBase()
96 { 96 {
97 MainLog.Instance.Verbose("ASSETSERVER", "Starting asset storage system"); 97 MainLog.Instance.Verbose("ASSETSERVER", "Starting asset storage system");
98 _assetRequests = new BlockingQueue<AssetRequest>(); 98 m_assetRequests = new BlockingQueue<AssetRequest>();
99 99
100 _localAssetServerThread = new Thread(RunRequests); 100 m_localAssetServerThread = new Thread(RunRequests);
101 _localAssetServerThread.IsBackground = true; 101 m_localAssetServerThread.IsBackground = true;
102 _localAssetServerThread.Start(); 102 m_localAssetServerThread.Start();
103 } 103 }
104 104
105 private void RunRequests() 105 private void RunRequests()
@@ -108,7 +108,7 @@ namespace OpenSim.Framework.Communications.Cache
108 { 108 {
109 try 109 try
110 { 110 {
111 AssetRequest req = _assetRequests.Dequeue(); 111 AssetRequest req = m_assetRequests.Dequeue();
112 112
113 ProcessRequest(req); 113 ProcessRequest(req);
114 } 114 }
@@ -121,7 +121,7 @@ namespace OpenSim.Framework.Communications.Cache
121 121
122 public void SetReceiver(IAssetReceiver receiver) 122 public void SetReceiver(IAssetReceiver receiver)
123 { 123 {
124 _receiver = receiver; 124 m_receiver = receiver;
125 } 125 }
126 126
127 public void RequestAsset(LLUUID assetID, bool isTexture) 127 public void RequestAsset(LLUUID assetID, bool isTexture)
@@ -129,23 +129,23 @@ namespace OpenSim.Framework.Communications.Cache
129 AssetRequest req = new AssetRequest(); 129 AssetRequest req = new AssetRequest();
130 req.AssetID = assetID; 130 req.AssetID = assetID;
131 req.IsTexture = isTexture; 131 req.IsTexture = isTexture;
132 _assetRequests.Enqueue(req); 132 m_assetRequests.Enqueue(req);
133 133
134 MainLog.Instance.Verbose("ASSET", "Added {0} to request queue", assetID); 134 MainLog.Instance.Verbose("ASSET", "Added {0} to request queue", assetID);
135 } 135 }
136 136
137 public virtual void UpdateAsset(AssetBase asset) 137 public virtual void UpdateAsset(AssetBase asset)
138 { 138 {
139 lock (syncLock) 139 lock (m_syncLock)
140 { 140 {
141 m_assetProviderPlugin.UpdateAsset(asset); 141 m_assetProvider.UpdateAsset(asset);
142 m_assetProviderPlugin.CommitAssets(); 142 m_assetProvider.CommitAssets();
143 } 143 }
144 } 144 }
145 145
146 public void StoreAndCommitAsset(AssetBase asset) 146 public void StoreAndCommitAsset(AssetBase asset)
147 { 147 {
148 lock (syncLock) 148 lock (m_syncLock)
149 { 149 {
150 StoreAsset(asset); 150 StoreAsset(asset);
151 CommitAssets(); 151 CommitAssets();
@@ -154,7 +154,7 @@ namespace OpenSim.Framework.Communications.Cache
154 154
155 public virtual void Close() 155 public virtual void Close()
156 { 156 {
157 _localAssetServerThread.Abort(); 157 m_localAssetServerThread.Abort();
158 } 158 }
159 159
160 public void SetServerInfo(string ServerUrl, string ServerKey) 160 public void SetServerInfo(string ServerUrl, string ServerKey)
diff --git a/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs b/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs
index e4c278f..0a141c3 100644
--- a/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs
+++ b/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs
@@ -40,7 +40,7 @@ namespace OpenSim.Framework.Communications.Cache
40 40
41 public SQLAssetServer(IAssetProvider assetProvider) 41 public SQLAssetServer(IAssetProvider assetProvider)
42 { 42 {
43 m_assetProviderPlugin = assetProvider; 43 m_assetProvider = assetProvider;
44 } 44 }
45 45
46 public void AddPlugin(string FileName) 46 public void AddPlugin(string FileName)
@@ -58,12 +58,12 @@ namespace OpenSim.Framework.Communications.Cache
58 { 58 {
59 IAssetProvider plug = 59 IAssetProvider plug =
60 (IAssetProvider) Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); 60 (IAssetProvider) Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
61 m_assetProviderPlugin = plug; 61 m_assetProvider = plug;
62 m_assetProviderPlugin.Initialise(); 62 m_assetProvider.Initialise();
63 63
64 MainLog.Instance.Verbose("AssetStorage", 64 MainLog.Instance.Verbose("AssetStorage",
65 "Added " + m_assetProviderPlugin.Name + " " + 65 "Added " + m_assetProvider.Name + " " +
66 m_assetProviderPlugin.Version); 66 m_assetProvider.Version);
67 } 67 }
68 } 68 }
69 } 69 }
@@ -74,15 +74,15 @@ namespace OpenSim.Framework.Communications.Cache
74 { 74 {
75 base.Close(); 75 base.Close();
76 76
77 m_assetProviderPlugin.CommitAssets(); 77 m_assetProvider.CommitAssets();
78 } 78 }
79 79
80 protected override AssetBase GetAsset(AssetRequest req) 80 protected override AssetBase GetAsset(AssetRequest req)
81 { 81 {
82 AssetBase asset; 82 AssetBase asset;
83 lock (syncLock) 83 lock (m_syncLock)
84 { 84 {
85 asset = m_assetProviderPlugin.FetchAsset(req.AssetID); 85 asset = m_assetProvider.FetchAsset(req.AssetID);
86 } 86 }
87 87
88 return asset; 88 return asset;
@@ -90,12 +90,12 @@ namespace OpenSim.Framework.Communications.Cache
90 90
91 protected override void StoreAsset(AssetBase asset) 91 protected override void StoreAsset(AssetBase asset)
92 { 92 {
93 m_assetProviderPlugin.CreateAsset(asset); 93 m_assetProvider.CreateAsset(asset);
94 } 94 }
95 95
96 protected override void CommitAssets() 96 protected override void CommitAssets()
97 { 97 {
98 m_assetProviderPlugin.CommitAssets(); 98 m_assetProvider.CommitAssets();
99 } 99 }
100 } 100 }
101} \ No newline at end of file 101} \ No newline at end of file
diff --git a/OpenSim/Region/ClientStack/ClientView.cs b/OpenSim/Region/ClientStack/ClientView.cs
index 414916c..066efef 100644
--- a/OpenSim/Region/ClientStack/ClientView.cs
+++ b/OpenSim/Region/ClientStack/ClientView.cs
@@ -2973,7 +2973,6 @@ namespace OpenSim.Region.ClientStack
2973 //Console.WriteLine("image request: " + Pack.ToString()); 2973 //Console.WriteLine("image request: " + Pack.ToString());
2974 for (int i = 0; i < imageRequest.RequestImage.Length; i++) 2974 for (int i = 0; i < imageRequest.RequestImage.Length; i++)
2975 { 2975 {
2976 // still working on the Texture download module so for now using old method
2977 if (OnRequestTexture != null) 2976 if (OnRequestTexture != null)
2978 { 2977 {
2979 TextureRequestArgs args = new TextureRequestArgs(); 2978 TextureRequestArgs args = new TextureRequestArgs();
@@ -2984,10 +2983,6 @@ namespace OpenSim.Region.ClientStack
2984 2983
2985 OnRequestTexture(this, args); 2984 OnRequestTexture(this, args);
2986 } 2985 }
2987
2988 // m_assetCache.AddTextureRequest(this, imageRequest.RequestImage[i].Image,
2989 // imageRequest.RequestImage[i].Packet,
2990 // imageRequest.RequestImage[i].DiscardLevel);
2991 } 2986 }
2992 break; 2987 break;
2993 case PacketType.TransferRequest: 2988 case PacketType.TransferRequest:
diff --git a/OpenSim/Region/Environment/Modules/TextureDownloadModule.cs b/OpenSim/Region/Environment/Modules/TextureDownloadModule.cs
index 813be8d..6d5d5e8 100644
--- a/OpenSim/Region/Environment/Modules/TextureDownloadModule.cs
+++ b/OpenSim/Region/Environment/Modules/TextureDownloadModule.cs
@@ -47,7 +47,7 @@ namespace OpenSim.Region.Environment.Modules
47 private Scene m_scene; 47 private Scene m_scene;
48 private List<Scene> m_scenes = new List<Scene>(); 48 private List<Scene> m_scenes = new List<Scene>();
49 49
50 private BlockingQueue<TextureSender> QueueSenders = new BlockingQueue<TextureSender>(); 50 private readonly BlockingQueue<TextureSender> m_queueSenders = new BlockingQueue<TextureSender>();
51 51
52 private Dictionary<LLUUID, UserTextureDownloadService> m_userTextureServices = 52 private Dictionary<LLUUID, UserTextureDownloadService> m_userTextureServices =
53 new Dictionary<LLUUID, UserTextureDownloadService>(); 53 new Dictionary<LLUUID, UserTextureDownloadService>();
@@ -108,7 +108,7 @@ namespace OpenSim.Region.Environment.Modules
108 return true; 108 return true;
109 } 109 }
110 110
111 textureService = new UserTextureDownloadService(m_scene, QueueSenders); 111 textureService = new UserTextureDownloadService(m_scene, m_queueSenders);
112 m_userTextureServices.Add(userID, textureService); 112 m_userTextureServices.Add(userID, textureService);
113 return true; 113 return true;
114 } 114 }
@@ -128,7 +128,7 @@ namespace OpenSim.Region.Environment.Modules
128 { 128 {
129 while (true) 129 while (true)
130 { 130 {
131 TextureSender sender = QueueSenders.Dequeue(); 131 TextureSender sender = m_queueSenders.Dequeue();
132 if (sender.Cancel) 132 if (sender.Cancel)
133 { 133 {
134 TextureSent(sender); 134 TextureSent(sender);
@@ -142,7 +142,7 @@ namespace OpenSim.Region.Environment.Modules
142 } 142 }
143 else 143 else
144 { 144 {
145 QueueSenders.Enqueue(sender); 145 m_queueSenders.Enqueue(sender);
146 } 146 }
147 } 147 }
148 } 148 }
@@ -155,11 +155,9 @@ namespace OpenSim.Region.Environment.Modules
155 155
156 public class UserTextureDownloadService 156 public class UserTextureDownloadService
157 { 157 {
158 private Dictionary<LLUUID, TextureSender> m_textureSenders = new Dictionary<LLUUID, TextureSender>(); 158 private readonly Dictionary<LLUUID, TextureSender> m_textureSenders = new Dictionary<LLUUID, TextureSender>();
159 159 private readonly BlockingQueue<TextureSender> m_sharedSendersQueue;
160 private BlockingQueue<TextureSender> m_sharedSendersQueue; 160 private readonly Scene m_scene;
161
162 private Scene m_scene;
163 161
164 public UserTextureDownloadService(Scene scene, BlockingQueue<TextureSender> sharedQueue) 162 public UserTextureDownloadService(Scene scene, BlockingQueue<TextureSender> sharedQueue)
165 { 163 {
@@ -169,38 +167,45 @@ namespace OpenSim.Region.Environment.Modules
169 167
170 public void HandleTextureRequest(IClientAPI client, TextureRequestArgs e) 168 public void HandleTextureRequest(IClientAPI client, TextureRequestArgs e)
171 { 169 {
170 TextureSender textureSender;
171
172 //TODO: should be working out the data size/ number of packets to be sent for each discard level 172 //TODO: should be working out the data size/ number of packets to be sent for each discard level
173 if ((e.DiscardLevel >= 0) || (e.Priority != 0)) 173 if ((e.DiscardLevel >= 0) || (e.Priority != 0))
174 { 174 {
175 lock (m_textureSenders) 175 lock (m_textureSenders)
176 { 176 {
177 if (!m_textureSenders.ContainsKey(e.RequestedAssetID)) 177 if (m_textureSenders.TryGetValue(e.RequestedAssetID, out textureSender))
178 {
179 textureSender.UpdateRequest(e.DiscardLevel, e.PacketNumber);
180 textureSender.counter = 0;
181
182 if ((textureSender.ImageLoaded) &&
183 (textureSender.Sending == false))
184 {
185 textureSender.Sending = true;
186
187 if (!m_sharedSendersQueue.Contains(textureSender))
188 {
189 m_sharedSendersQueue.Enqueue(textureSender);
190 }
191 }
192 }
193 else
178 { 194 {
179 TextureSender requestHandler = 195 TextureSender requestHandler =
180 new TextureSender(client, e.RequestedAssetID, e.DiscardLevel, e.PacketNumber); 196 new TextureSender(client, e.RequestedAssetID, e.DiscardLevel, e.PacketNumber);
181 m_textureSenders.Add(e.RequestedAssetID, requestHandler); 197 m_textureSenders.Add(e.RequestedAssetID, requestHandler);
182 m_scene.AssetCache.GetAsset(e.RequestedAssetID, TextureCallback); 198 m_scene.AssetCache.GetAsset(e.RequestedAssetID, TextureCallback);
183 } 199 }
184 else
185 {
186 m_textureSenders[e.RequestedAssetID].UpdateRequest(e.DiscardLevel, e.PacketNumber);
187 m_textureSenders[e.RequestedAssetID].counter = 0;
188 if ((m_textureSenders[e.RequestedAssetID].ImageLoaded) &&
189 (m_textureSenders[e.RequestedAssetID].Sending == false))
190 {
191 m_textureSenders[e.RequestedAssetID].Sending = true;
192 m_sharedSendersQueue.Enqueue(m_textureSenders[e.RequestedAssetID]);
193 }
194 }
195 } 200 }
196 } 201 }
197 else 202 else
198 { 203 {
199 lock (m_textureSenders) 204 lock (m_textureSenders)
200 { 205 {
201 if (m_textureSenders.ContainsKey(e.RequestedAssetID)) 206 if (m_textureSenders.TryGetValue(e.RequestedAssetID, out textureSender))
202 { 207 {
203 m_textureSenders[e.RequestedAssetID].Cancel = true; 208 textureSender.Cancel = true;
204 } 209 }
205 } 210 }
206 } 211 }
@@ -210,19 +215,25 @@ namespace OpenSim.Region.Environment.Modules
210 { 215 {
211 lock (m_textureSenders) 216 lock (m_textureSenders)
212 { 217 {
213 if (m_textureSenders.ContainsKey(textureID)) 218 TextureSender textureSender;
219
220 if (m_textureSenders.TryGetValue(textureID, out textureSender))
214 { 221 {
215 if (!m_textureSenders[textureID].ImageLoaded) 222 if (!textureSender.ImageLoaded)
216 { 223 {
217 m_textureSenders[textureID].TextureReceived(asset); 224 textureSender.TextureReceived(asset);
218 m_textureSenders[textureID].Sending = true; 225 textureSender.Sending = true;
219 m_textureSenders[textureID].counter = 0; 226 textureSender.counter = 0;
220 m_sharedSendersQueue.Enqueue(m_textureSenders[textureID]); 227
228 if (!m_sharedSendersQueue.Contains(textureSender))
229 {
230 m_sharedSendersQueue.Enqueue(textureSender);
231 }
221 } 232 }
222 } 233 }
223 else 234 else
224 { 235 {
225 // Got a texture with no sender object to handle it, this shouldn't happen 236 throw new Exception("Got a texture with no sender object to handle it, this shouldn't happen");
226 } 237 }
227 } 238 }
228 } 239 }
@@ -329,9 +340,9 @@ namespace OpenSim.Region.Environment.Modules
329 } 340 }
330 catch (ArgumentOutOfRangeException) 341 catch (ArgumentOutOfRangeException)
331 { 342 {
332 MainLog.Instance.Warn("TEXTURE", 343 MainLog.Instance.Error("TEXTURE",
333 "Unable to separate texture into multiple packets: Array bounds failure on asset:" + 344 "Unable to separate texture into multiple packets: Array bounds failure on asset:" +
334 m_asset.FullID.ToString() + "- TextureDownloadModule.cs. line:328"); 345 m_asset.FullID.ToString() );
335 return; 346 return;
336 } 347 }
337 RequestUser.OutPacket(im, ThrottleOutPacketType.Texture); 348 RequestUser.OutPacket(im, ThrottleOutPacketType.Texture);