aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework
diff options
context:
space:
mode:
authorTleiades Hax2007-10-26 11:46:27 +0000
committerTleiades Hax2007-10-26 11:46:27 +0000
commit5e7dba726896fcb84882b53952651742926e6efb (patch)
treea396337e721912fd954e8a66e26d16c375d7bab4 /OpenSim/Framework
parentadd my set-eol-style script. Can be run on Linux (diff)
downloadopensim-SC_OLD-5e7dba726896fcb84882b53952651742926e6efb.zip
opensim-SC_OLD-5e7dba726896fcb84882b53952651742926e6efb.tar.gz
opensim-SC_OLD-5e7dba726896fcb84882b53952651742926e6efb.tar.bz2
opensim-SC_OLD-5e7dba726896fcb84882b53952651742926e6efb.tar.xz
Very early first implementation of grid based assets.
Run this on a major grid, and weep
Diffstat (limited to '')
-rw-r--r--OpenSim/Framework/Communications/Cache/AssetCache.cs11
-rw-r--r--OpenSim/Framework/Communications/Cache/AssetServerBase.cs36
-rw-r--r--OpenSim/Framework/Communications/Cache/GridAssetClient.cs160
-rw-r--r--OpenSim/Framework/Communications/RestClient/GenericAsyncResult.cs2
-rw-r--r--OpenSim/Framework/Communications/RestClient/RestClient.cs101
-rw-r--r--OpenSim/Framework/Data.MySQL/MySQLAssetData.cs30
-rw-r--r--OpenSim/Framework/General/Types/AssetBase.cs2
7 files changed, 290 insertions, 52 deletions
diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs
index 271934f..95183ad 100644
--- a/OpenSim/Framework/Communications/Cache/AssetCache.cs
+++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs
@@ -36,6 +36,7 @@ using libsecondlife.Packets;
36using OpenSim.Framework.Interfaces; 36using OpenSim.Framework.Interfaces;
37using OpenSim.Framework.Types; 37using OpenSim.Framework.Types;
38using OpenSim.Framework.Utilities; 38using OpenSim.Framework.Utilities;
39using OpenSim.Framework.Console;
39 40
40namespace OpenSim.Framework.Communications.Cache 41namespace OpenSim.Framework.Communications.Cache
41{ 42{
@@ -319,17 +320,19 @@ namespace OpenSim.Framework.Communications.Cache
319 320
320 public void AssetNotFound(LLUUID assetID) 321 public void AssetNotFound(LLUUID assetID)
321 { 322 {
322 /*
323 if (this.RequestedTextures.ContainsKey(assetID)) 323 if (this.RequestedTextures.ContainsKey(assetID))
324 { 324 {
325 MainLog.Instance.Warn("ASSET CACHE", "sending image not found for {0}", assetID);
325 AssetRequest req = this.RequestedTextures[assetID]; 326 AssetRequest req = this.RequestedTextures[assetID];
326 ImageNotInDatabasePacket notFound = new ImageNotInDatabasePacket(); 327 ImageNotInDatabasePacket notFound = new ImageNotInDatabasePacket();
327 notFound.ImageID.ID = assetID; 328 notFound.ImageID.ID = assetID;
328 req.RequestUser.OutPacket(notFound); 329 req.RequestUser.OutPacket(notFound);
329 //Console.WriteLine("sending image not found for " + assetID);
330
331 this.RequestedTextures.Remove(assetID); 330 this.RequestedTextures.Remove(assetID);
332 }*/ 331 }
332 else
333 {
334 MainLog.Instance.Error("ASSET CACHE", "Cound not send image not found for {0}", assetID);
335 }
333 } 336 }
334 337
335 #region Assets 338 #region Assets
diff --git a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs
index a3ec346..53efa16 100644
--- a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs
+++ b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs
@@ -108,23 +108,23 @@ namespace OpenSim.Framework.Communications.Cache
108 public virtual List<AssetBase> GetDefaultAssets() 108 public virtual List<AssetBase> GetDefaultAssets()
109 { 109 {
110 List<AssetBase> assets = new List<AssetBase>(); 110 List<AssetBase> assets = new List<AssetBase>();
111 111 // These assets have been moved into the OpenSimAssetSet.XML file
112 assets.Add(CreateImageAsset("00000000-0000-0000-9999-000000000001", "Bricks", "bricks.jp2")); 112 //assets.Add(CreateImageAsset("00000000-0000-1111-9999-000000000001", "Bricks", "bricks.jp2"));
113 assets.Add(CreateImageAsset("00000000-0000-0000-9999-000000000002", "Plywood", "plywood.jp2")); 113 //assets.Add(CreateImageAsset("00000000-0000-1111-9999-000000000002", "Plywood", "plywood.jp2"));
114 assets.Add(CreateImageAsset("00000000-0000-0000-9999-000000000003", "Rocks", "rocks.jp2")); 114 //assets.Add(CreateImageAsset("00000000-0000-1111-9999-000000000003", "Rocks", "rocks.jp2"));
115 assets.Add(CreateImageAsset("00000000-0000-0000-9999-000000000004", "Granite", "granite.jp2")); 115 //assets.Add(CreateImageAsset("00000000-0000-1111-9999-000000000004", "Granite", "granite.jp2"));
116 assets.Add(CreateImageAsset("00000000-0000-0000-9999-000000000005", "Hardwood", "hardwood.jp2")); 116 //assets.Add(CreateImageAsset("00000000-0000-1111-9999-000000000005", "Hardwood", "hardwood.jp2"));
117 assets.Add(CreateImageAsset("00000000-0000-0000-5005-000000000005", "Prim Base Texture", "plywood.jp2")); 117 //assets.Add(CreateImageAsset("00000000-0000-1111-5005-000000000005", "Prim Base Texture", "plywood.jp2"));
118 assets.Add(CreateImageAsset("00000000-0000-0000-9999-000000000006", "Map Base Texture", "map_base.jp2")); 118 //assets.Add(CreateImageAsset("00000000-0000-1111-9999-000000000006", "Map Base Texture", "map_base.jp2"));
119 assets.Add(CreateImageAsset("00000000-0000-0000-9999-000000000007", "Map Texture", "map1.jp2")); 119 //assets.Add(CreateImageAsset("00000000-0000-1111-9999-000000000007", "Map Texture", "map1.jp2"));
120 assets.Add(CreateImageAsset("00000000-0000-0000-9999-000000000010", "Female Body Texture", "femalebody.jp2")); 120 //assets.Add(CreateImageAsset("00000000-0000-1111-9999-000000000010", "Female Body Texture", "femalebody.jp2"));
121 assets.Add(CreateImageAsset("00000000-0000-0000-9999-000000000011", "Female Bottom Texture", "femalebottom.jp2")); 121 //assets.Add(CreateImageAsset("00000000-0000-1111-9999-000000000011", "Female Bottom Texture", "femalebottom.jp2"));
122 assets.Add(CreateImageAsset("00000000-0000-0000-9999-000000000012", "Female Face Texture", "femaleface.jp2")); 122 //assets.Add(CreateImageAsset("00000000-0000-1111-9999-000000000012", "Female Face Texture", "femaleface.jp2"));
123 123
124 assets.Add(CreateAsset("77c41e39-38f9-f75a-024e-585989bbabbb", "Skin", "base_skin.dat", false)); 124 //assets.Add(CreateAsset("77c41e39-38f9-f75a-024e-585989bbabbb", "Skin", "base_skin.dat", false));
125 assets.Add(CreateAsset("66c41e39-38f9-f75a-024e-585989bfab73", "Shape", "base_shape.dat", false)); 125 //assets.Add(CreateAsset("66c41e39-38f9-f75a-024e-585989bfab73", "Shape", "base_shape.dat", false));
126 assets.Add(CreateAsset("00000000-38f9-1111-024e-222222111110", "Shirt", "newshirt.dat", false)); 126 //assets.Add(CreateAsset("00000000-38f9-1111-024e-222222111110", "Shirt", "newshirt.dat", false));
127 assets.Add(CreateAsset("00000000-38f9-1111-024e-222222111120", "Shirt", "newpants.dat", false)); 127 //assets.Add(CreateAsset("00000000-38f9-1111-024e-222222111120", "Shirt", "newpants.dat", false));
128 128
129 return assets; 129 return assets;
130 } 130 }
@@ -185,4 +185,4 @@ namespace OpenSim.Framework.Communications.Cache
185 } 185 }
186 } 186 }
187 } 187 }
188} \ No newline at end of file 188}
diff --git a/OpenSim/Framework/Communications/Cache/GridAssetClient.cs b/OpenSim/Framework/Communications/Cache/GridAssetClient.cs
new file mode 100644
index 0000000..fc77431
--- /dev/null
+++ b/OpenSim/Framework/Communications/Cache/GridAssetClient.cs
@@ -0,0 +1,160 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
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
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
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28using System;
29using System.IO;
30using System.Threading;
31using System.Reflection;
32using System.Xml.Serialization;
33
34using libsecondlife;
35
36using Nini.Config;
37using OpenSim.Framework.Console;
38using OpenSim.Framework.Interfaces;
39using OpenSim.Framework.Types;
40using OpenSim.Framework.Utilities;
41using OpenSim.Framework.Communications;
42
43namespace OpenSim.Framework.Communications.Cache
44{
45 public class GridAssetClient : IAssetServer
46 {
47 private string _assetServerUrl;
48 private IAssetReceiver _receiver;
49
50 public GridAssetClient(string serverUrl)
51 {
52 _assetServerUrl = serverUrl;
53 }
54
55 #region IAssetServer Members
56
57 public void SetReceiver(IAssetReceiver receiver)
58 {
59 _receiver = receiver;
60 }
61
62 public void FetchAsset(LLUUID assetID, bool isTexture)
63 {
64 Stream s = null;
65 try
66 {
67
68 MainLog.Instance.Debug("ASSETCACHE", "Querying for {0}", assetID.ToString());
69
70 RestClient rc = new RestClient(_assetServerUrl);
71 rc.AddResourcePath("assets");
72 rc.AddResourcePath(assetID.ToString());
73 if (isTexture)
74 rc.AddQueryParameter("texture");
75
76 rc.RequestMethod = "GET";
77 s = rc.Request();
78
79 if (s.Length > 0)
80 {
81 XmlSerializer xs = new XmlSerializer(typeof(AssetBase));
82 AssetBase asset = (AssetBase)xs.Deserialize(s);
83
84 _receiver.AssetReceived(asset, isTexture);
85 }
86 else
87 {
88 MainLog.Instance.Debug("ASSETCACHE", "Asset not found {0}", assetID.ToString());
89 _receiver.AssetNotFound(assetID);
90 }
91 }
92 catch (Exception e)
93 {
94 MainLog.Instance.Error("ASSETCACHE", e.Message);
95 MainLog.Instance.Error("ASSETCACHE", e.StackTrace);
96 }
97 }
98
99 public void UpdateAsset(AssetBase asset)
100 {
101 throw new Exception("The method or operation is not implemented.");
102 }
103
104 public void StoreAndCommitAsset(AssetBase asset)
105 {
106 try
107 {
108 MemoryStream s = new MemoryStream();
109
110 XmlSerializer xs = new XmlSerializer(typeof(AssetBase));
111 xs.Serialize(s, asset);
112 RestClient rc = new RestClient(_assetServerUrl);
113 rc.AddResourcePath("assets");
114 rc.RequestMethod = "POST";
115 rc.Request(s);
116 }
117 catch (Exception e)
118 {
119 MainLog.Instance.Error("ASSETS", e.Message);
120 }
121 }
122
123 public void Close()
124 {
125 throw new Exception("The method or operation is not implemented.");
126 }
127
128 public void LoadAsset(AssetBase info, bool image, string filename)
129 {
130 throw new Exception("The method or operation is not implemented.");
131 }
132
133 public System.Collections.Generic.List<AssetBase> GetDefaultAssets()
134 {
135 throw new Exception("The method or operation is not implemented.");
136 }
137
138 public AssetBase CreateImageAsset(string assetIdStr, string name, string filename)
139 {
140 throw new Exception("The method or operation is not implemented.");
141 }
142
143 public void ForEachDefaultAsset(Action<AssetBase> action)
144 {
145 throw new Exception("The method or operation is not implemented.");
146 }
147
148 public AssetBase CreateAsset(string assetIdStr, string name, string filename, bool isImage)
149 {
150 throw new Exception("The method or operation is not implemented.");
151 }
152
153 public void ForEachXmlAsset(Action<AssetBase> action)
154 {
155 throw new Exception("The method or operation is not implemented.");
156 }
157
158 #endregion
159 }
160}
diff --git a/OpenSim/Framework/Communications/RestClient/GenericAsyncResult.cs b/OpenSim/Framework/Communications/RestClient/GenericAsyncResult.cs
index 55456ae..c821fa4 100644
--- a/OpenSim/Framework/Communications/RestClient/GenericAsyncResult.cs
+++ b/OpenSim/Framework/Communications/RestClient/GenericAsyncResult.cs
@@ -3,7 +3,7 @@ using System.Collections.Generic;
3using System.Text; 3using System.Text;
4using System.Threading; 4using System.Threading;
5 5
6namespace OpenSim.Framework.RestClient 6namespace OpenSim.Framework.Communications
7{ 7{
8 internal class SimpleAsyncResult : IAsyncResult 8 internal class SimpleAsyncResult : IAsyncResult
9 { 9 {
diff --git a/OpenSim/Framework/Communications/RestClient/RestClient.cs b/OpenSim/Framework/Communications/RestClient/RestClient.cs
index 25fc61a..392669f 100644
--- a/OpenSim/Framework/Communications/RestClient/RestClient.cs
+++ b/OpenSim/Framework/Communications/RestClient/RestClient.cs
@@ -6,7 +6,9 @@ using System.Text;
6using System.Collections.Generic; 6using System.Collections.Generic;
7using System.Threading; 7using System.Threading;
8 8
9namespace OpenSim.Framework.RestClient 9using OpenSim.Framework.Console;
10
11namespace OpenSim.Framework.Communications
10{ 12{
11 /// <summary> 13 /// <summary>
12 /// Implementation of a generic REST client 14 /// Implementation of a generic REST client
@@ -25,8 +27,11 @@ namespace OpenSim.Framework.RestClient
25 /// other threads to execute, while it waits for a response from the web-service. RestClient it self, can be 27 /// other threads to execute, while it waits for a response from the web-service. RestClient it self, can be
26 /// invoked by the caller in either synchroneous mode or asynchroneous mode. 28 /// invoked by the caller in either synchroneous mode or asynchroneous mode.
27 /// </remarks> 29 /// </remarks>
28 public class RestClient 30 public class RestClient
29 { 31 {
32
33 string realuri;
34 #region member variables
30 /// <summary> 35 /// <summary>
31 /// The base Uri of the web-service e.g. http://www.google.com 36 /// The base Uri of the web-service e.g. http://www.google.com
32 /// </summary> 37 /// </summary>
@@ -55,7 +60,7 @@ namespace OpenSim.Framework.RestClient
55 /// <summary> 60 /// <summary>
56 /// MemoryStream representing the resultiong resource 61 /// MemoryStream representing the resultiong resource
57 /// </summary> 62 /// </summary>
58 MemoryStream _resource; 63 Stream _resource;
59 64
60 /// <summary> 65 /// <summary>
61 /// WebRequest object, held as a member variable 66 /// WebRequest object, held as a member variable
@@ -89,6 +94,9 @@ namespace OpenSim.Framework.RestClient
89 /// </summary> 94 /// </summary>
90 private Exception _asyncException; 95 private Exception _asyncException;
91 96
97 #endregion member variables
98
99 #region constructors
92 /// <summary> 100 /// <summary>
93 /// Instantiate a new RestClient 101 /// Instantiate a new RestClient
94 /// </summary> 102 /// </summary>
@@ -100,8 +108,12 @@ namespace OpenSim.Framework.RestClient
100 _resource = new MemoryStream(); 108 _resource = new MemoryStream();
101 _request = null; 109 _request = null;
102 _response = null; 110 _response = null;
111 _lock = new object();
103 } 112 }
104 113
114 object _lock;
115 #endregion constructors
116
105 /// <summary> 117 /// <summary>
106 /// Add a path element to the query, e.g. assets 118 /// Add a path element to the query, e.g. assets
107 /// </summary> 119 /// </summary>
@@ -125,6 +137,15 @@ namespace OpenSim.Framework.RestClient
125 } 137 }
126 138
127 /// <summary> 139 /// <summary>
140 /// Add a query parameter to the Url
141 /// </summary>
142 /// <param name="name">Name of the parameter, e.g. min</param>
143 public void AddQueryParameter(string name)
144 {
145 _parameterElements.Add(HttpUtility.UrlEncode(name), null);
146 }
147
148 /// <summary>
128 /// Web-Request method, e.g. GET, PUT, POST, DELETE 149 /// Web-Request method, e.g. GET, PUT, POST, DELETE
129 /// </summary> 150 /// </summary>
130 public string RequestMethod 151 public string RequestMethod
@@ -185,9 +206,10 @@ namespace OpenSim.Framework.RestClient
185 sb.Append(kv.Value); 206 sb.Append(kv.Value);
186 } 207 }
187 } 208 }
209 realuri = sb.ToString();
188 return new Uri(sb.ToString()); 210 return new Uri(sb.ToString());
189 } 211 }
190 212 #region Async communications with server
191 /// <summary> 213 /// <summary>
192 /// Async method, invoked when a block of data has been received from the service 214 /// Async method, invoked when a block of data has been received from the service
193 /// </summary> 215 /// </summary>
@@ -199,7 +221,6 @@ namespace OpenSim.Framework.RestClient
199 Stream s = (Stream)ar.AsyncState; 221 Stream s = (Stream)ar.AsyncState;
200 int read = s.EndRead(ar); 222 int read = s.EndRead(ar);
201 223
202 // Read the HTML page and then print it to the console.
203 if (read > 0) 224 if (read > 0)
204 { 225 {
205 _resource.Write(_readbuf, 0, read); 226 _resource.Write(_readbuf, 0, read);
@@ -207,7 +228,6 @@ namespace OpenSim.Framework.RestClient
207 228
208 // TODO! Implement timeout, without killing the server 229 // TODO! Implement timeout, without killing the server
209 //ThreadPool.RegisterWaitForSingleObject(asynchronousResult.AsyncWaitHandle, new WaitOrTimerCallback(TimeoutCallback), _request, DefaultTimeout, true); 230 //ThreadPool.RegisterWaitForSingleObject(asynchronousResult.AsyncWaitHandle, new WaitOrTimerCallback(TimeoutCallback), _request, DefaultTimeout, true);
210 return;
211 } 231 }
212 else 232 else
213 { 233 {
@@ -261,32 +281,83 @@ namespace OpenSim.Framework.RestClient
261 } 281 }
262 } 282 }
263 } 283 }
284 #endregion Async communications with server
264 285
265 /// <summary> 286 /// <summary>
266 /// Perform synchroneous request 287 /// Perform synchroneous request
267 /// </summary> 288 /// </summary>
268 public Stream Request() 289 public Stream Request()
269 { 290 {
291 lock (_lock)
292 {
293 _request = (HttpWebRequest)WebRequest.Create(buildUri());
294 _request.KeepAlive = false;
295 _request.ContentType = "application/xml";
296 _request.Timeout = 200000;
297 _asyncException = null;
298
299// IAsyncResult responseAsyncResult = _request.BeginGetResponse(new AsyncCallback(ResponseIsReadyDelegate), _request);
300 _response = (HttpWebResponse)_request.GetResponse();
301 Stream src = _response.GetResponseStream();
302 int length = src.Read(_readbuf, 0, BufferSize);
303 while(length > 0)
304 {
305 _resource.Write(_readbuf, 0, length);
306 length = src.Read(_readbuf, 0, BufferSize);
307 }
308
309
310 // TODO! Implement timeout, without killing the server
311 // this line implements the timeout, if there is a timeout, the callback fires and the request becomes aborted
312 //ThreadPool.RegisterWaitForSingleObject(responseAsyncResult.AsyncWaitHandle, new WaitOrTimerCallback(TimeoutCallback), _request, DefaultTimeout, true);
313
314// _allDone.WaitOne();
315 if (_response != null)
316 _response.Close();
317 if (_asyncException != null)
318 throw _asyncException;
319
320 if (_resource != null)
321 {
322 _resource.Flush();
323 _resource.Seek(0, SeekOrigin.Begin);
324 }
325
326 return _resource;
327 }
328 }
329
330 public Stream Request(Stream src)
331 {
270 _request = (HttpWebRequest)WebRequest.Create(buildUri()); 332 _request = (HttpWebRequest)WebRequest.Create(buildUri());
271 _request.KeepAlive = false; 333 _request.KeepAlive = false;
272 _request.ContentType = "text/html"; 334 _request.ContentType = "application/xml";
273 _request.Timeout = 200; 335 _request.Timeout = 900000;
336 _request.Method = RequestMethod;
274 _asyncException = null; 337 _asyncException = null;
338 _request.ContentLength = src.Length;
275 339
276 IAsyncResult responseAsyncResult = _request.BeginGetResponse(new AsyncCallback(ResponseIsReadyDelegate), _request); 340 src.Seek(0, SeekOrigin.Begin);
341 Stream dst = _request.GetRequestStream();
342 byte[] buf = new byte[1024];
343 int length = src.Read(buf,0, 1024);
344 while (length > 0)
345 {
346 dst.Write(buf, 0, length);
347 length = src.Read(buf, 0, 1024);
348 }
349 _response = (HttpWebResponse)_request.GetResponse();
350
351// IAsyncResult responseAsyncResult = _request.BeginGetResponse(new AsyncCallback(ResponseIsReadyDelegate), _request);
277 352
278 // TODO! Implement timeout, without killing the server 353 // TODO! Implement timeout, without killing the server
279 // this line implements the timeout, if there is a timeout, the callback fires and the request becomes aborted 354 // this line implements the timeout, if there is a timeout, the callback fires and the request becomes aborted
280 //ThreadPool.RegisterWaitForSingleObject(responseAsyncResult.AsyncWaitHandle, new WaitOrTimerCallback(TimeoutCallback), _request, DefaultTimeout, true); 355 //ThreadPool.RegisterWaitForSingleObject(responseAsyncResult.AsyncWaitHandle, new WaitOrTimerCallback(TimeoutCallback), _request, DefaultTimeout, true);
281 356
282 _allDone.WaitOne(); 357 return null;
283 if(_response != null)
284 _response.Close();
285 if (_asyncException != null)
286 throw _asyncException;
287 return _resource;
288 } 358 }
289 359
360
290 #region Async Invocation 361 #region Async Invocation
291 public IAsyncResult BeginRequest(AsyncCallback callback, object state) 362 public IAsyncResult BeginRequest(AsyncCallback callback, object state)
292 { 363 {
diff --git a/OpenSim/Framework/Data.MySQL/MySQLAssetData.cs b/OpenSim/Framework/Data.MySQL/MySQLAssetData.cs
index a8f0fdb..0112474 100644
--- a/OpenSim/Framework/Data.MySQL/MySQLAssetData.cs
+++ b/OpenSim/Framework/Data.MySQL/MySQLAssetData.cs
@@ -71,22 +71,24 @@ namespace OpenSim.Framework.Data.MySQL
71 public AssetBase FetchAsset(LLUUID assetID) 71 public AssetBase FetchAsset(LLUUID assetID)
72 { 72 {
73 AssetBase asset = null; 73 AssetBase asset = null;
74 74 lock (_dbConnection)
75 MySqlCommand cmd = new MySqlCommand("SELECT name, description, assetType, invType, local, temporary, data FROM assets WHERE id=?id", _dbConnection.Connection);
76 MySqlParameter p = cmd.Parameters.Add("?id", MySqlDbType.Binary, 16);
77 p.Value = assetID.GetBytes();
78 using (MySqlDataReader dbReader = cmd.ExecuteReader(System.Data.CommandBehavior.SingleRow))
79 { 75 {
80 if (dbReader.Read()) 76 MySqlCommand cmd = new MySqlCommand("SELECT name, description, assetType, invType, local, temporary, data FROM assets WHERE id=?id", _dbConnection.Connection);
77 MySqlParameter p = cmd.Parameters.Add("?id", MySqlDbType.Binary, 16);
78 p.Value = assetID.GetBytes();
79 using (MySqlDataReader dbReader = cmd.ExecuteReader(System.Data.CommandBehavior.SingleRow))
81 { 80 {
82 asset = new AssetBase(); 81 if (dbReader.Read())
83 asset.Data = (byte[])dbReader["data"]; 82 {
84 asset.Description = (string)dbReader["description"]; 83 asset = new AssetBase();
85 asset.FullID = assetID; 84 asset.Data = (byte[])dbReader["data"];
86 asset.InvType = (sbyte)dbReader["invType"]; 85 asset.Description = (string)dbReader["description"];
87 asset.Local = ((sbyte)dbReader["local"]) != 0 ? true : false; 86 asset.FullID = assetID;
88 asset.Name = (string)dbReader["name"]; 87 asset.InvType = (sbyte)dbReader["invType"];
89 asset.Type = (sbyte)dbReader["assetType"]; 88 asset.Local = ((sbyte)dbReader["local"]) != 0 ? true : false;
89 asset.Name = (string)dbReader["name"];
90 asset.Type = (sbyte)dbReader["assetType"];
91 }
90 } 92 }
91 } 93 }
92 return asset; 94 return asset;
diff --git a/OpenSim/Framework/General/Types/AssetBase.cs b/OpenSim/Framework/General/Types/AssetBase.cs
index 628724d..c34887c 100644
--- a/OpenSim/Framework/General/Types/AssetBase.cs
+++ b/OpenSim/Framework/General/Types/AssetBase.cs
@@ -25,10 +25,12 @@
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 libsecondlife; 29using libsecondlife;
29 30
30namespace OpenSim.Framework.Types 31namespace OpenSim.Framework.Types
31{ 32{
33 [Serializable]
32 public class AssetBase 34 public class AssetBase
33 { 35 {
34 public byte[] Data; 36 public byte[] Data;