aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Communications
diff options
context:
space:
mode:
authorJustin Clarke Casey2009-04-14 17:44:10 +0000
committerJustin Clarke Casey2009-04-14 17:44:10 +0000
commite1c449b492a08b95e9f4ea0556b6ec77f32ef0e7 (patch)
treeb2a678fcd49554c33ca354590cebb0b8ced34896 /OpenSim/Framework/Communications
parentChanging the CAP seed to be the string representation of a full UUID, instead... (diff)
downloadopensim-SC_OLD-e1c449b492a08b95e9f4ea0556b6ec77f32ef0e7.zip
opensim-SC_OLD-e1c449b492a08b95e9f4ea0556b6ec77f32ef0e7.tar.gz
opensim-SC_OLD-e1c449b492a08b95e9f4ea0556b6ec77f32ef0e7.tar.bz2
opensim-SC_OLD-e1c449b492a08b95e9f4ea0556b6ec77f32ef0e7.tar.xz
* Change simple asset cache test to manually pump the asset server rather than relying on another thread
Diffstat (limited to 'OpenSim/Framework/Communications')
-rw-r--r--OpenSim/Framework/Communications/Cache/AssetServerBase.cs29
-rw-r--r--OpenSim/Framework/Communications/Tests/Cache/AssetCacheTests.cs15
2 files changed, 28 insertions, 16 deletions
diff --git a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs
index 343667a..24cb598 100644
--- a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs
+++ b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs
@@ -138,14 +138,29 @@ namespace OpenSim.Framework.Communications.Cache
138 /// asset cannot be found. 138 /// asset cannot be found.
139 /// </exception> 139 /// </exception>
140 protected abstract AssetBase GetAsset(AssetRequest req); 140 protected abstract AssetBase GetAsset(AssetRequest req);
141 141
142 /// <summary>
143 /// Does the asset server have any waiting requests?
144 /// </summary>
145 ///
146 /// This does include any request that is currently being handled. This information is not reliable where
147 /// another thread may be processing requests.
148 ///
149 /// <returns>
150 /// True if there are waiting requests. False if there are no waiting requests.
151 /// </returns>
152 public virtual bool HasWaitingRequests()
153 {
154 return m_assetRequests.Count() != 0;
155 }
156
142 /// <summary> 157 /// <summary>
143 /// Process an asset request. This method will call GetAsset(AssetRequest req) 158 /// Process an asset request. This method will call GetAsset(AssetRequest req)
144 /// on the subclass. 159 /// on the subclass.
145 /// </summary> 160 /// </summary>
146 /// <param name="req"></param> 161 public virtual void ProcessNextRequest()
147 protected virtual void ProcessRequest(AssetRequest req)
148 { 162 {
163 AssetRequest req = m_assetRequests.Dequeue();
149 AssetBase asset; 164 AssetBase asset;
150 165
151 try 166 try
@@ -160,7 +175,7 @@ namespace OpenSim.Framework.Communications.Cache
160 StatsManager.SimExtraStats.AddAssetServiceRequestFailure(); 175 StatsManager.SimExtraStats.AddAssetServiceRequestFailure();
161 176
162 m_receiver.AssetNotFound(req.AssetID, req.IsTexture); 177 m_receiver.AssetNotFound(req.AssetID, req.IsTexture);
163 178
164 return; 179 return;
165 } 180 }
166 181
@@ -190,10 +205,8 @@ namespace OpenSim.Framework.Communications.Cache
190 while (true) // Since it's a 'blocking queue' 205 while (true) // Since it's a 'blocking queue'
191 { 206 {
192 try 207 try
193 { 208 {
194 AssetRequest req = m_assetRequests.Dequeue(); 209 ProcessNextRequest();
195
196 ProcessRequest(req);
197 } 210 }
198 catch (Exception e) 211 catch (Exception e)
199 { 212 {
diff --git a/OpenSim/Framework/Communications/Tests/Cache/AssetCacheTests.cs b/OpenSim/Framework/Communications/Tests/Cache/AssetCacheTests.cs
index 264bfe1..5d6bc8d 100644
--- a/OpenSim/Framework/Communications/Tests/Cache/AssetCacheTests.cs
+++ b/OpenSim/Framework/Communications/Tests/Cache/AssetCacheTests.cs
@@ -62,15 +62,14 @@ namespace OpenSim.Framework.Communications.Tests
62 TestAssetDataPlugin assetPlugin = new TestAssetDataPlugin(); 62 TestAssetDataPlugin assetPlugin = new TestAssetDataPlugin();
63 assetPlugin.CreateAsset(asset); 63 assetPlugin.CreateAsset(asset);
64 64
65 IAssetServer assetServer = new SQLAssetServer(assetPlugin); 65 SQLAssetServer assetServer = new SQLAssetServer(assetPlugin);
66 IAssetCache assetCache = new AssetCache(assetServer); 66 IAssetCache assetCache = new AssetCache(assetServer);
67 assetServer.Start(); 67
68 68 assetCache.GetAsset(assetId, AssetRequestCallback, false);
69 lock (this) 69
70 { 70 // Manually pump the asset server
71 assetCache.GetAsset(assetId, AssetRequestCallback, false); 71 while (assetServer.HasWaitingRequests())
72 Monitor.Wait(this, 60000); 72 assetServer.ProcessNextRequest();
73 }
74 73
75 Assert.That( 74 Assert.That(
76 assetId, Is.EqualTo(m_assetIdReceived), "Asset id stored differs from asset id received"); 75 assetId, Is.EqualTo(m_assetIdReceived), "Asset id stored differs from asset id received");