diff options
Diffstat (limited to 'OpenSim/Region')
8 files changed, 256 insertions, 135 deletions
diff --git a/OpenSim/Region/Environment/Modules/Agent/TextureDownload/TextureDownloadModule.cs b/OpenSim/Region/Environment/Modules/Agent/TextureDownload/TextureDownloadModule.cs index 35fa5ed..2f5ea23 100644 --- a/OpenSim/Region/Environment/Modules/Agent/TextureDownload/TextureDownloadModule.cs +++ b/OpenSim/Region/Environment/Modules/Agent/TextureDownload/TextureDownloadModule.cs | |||
@@ -241,44 +241,52 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureDownload | |||
241 | { | 241 | { |
242 | ITextureSender sender = null; | 242 | ITextureSender sender = null; |
243 | 243 | ||
244 | try | 244 | // try |
245 | { | 245 | // { |
246 | while (true) | 246 | while (true) |
247 | { | 247 | { |
248 | sender = m_queueSenders.Dequeue(); | 248 | try |
249 | |||
250 | if (sender.Cancel) | ||
251 | { | 249 | { |
252 | TextureSent(sender); | 250 | sender = m_queueSenders.Dequeue(); |
253 | 251 | ||
254 | sender.Cancel = false; | 252 | if (sender.Cancel) |
255 | } | ||
256 | else | ||
257 | { | ||
258 | bool finished = sender.SendTexturePacket(); | ||
259 | if (finished) | ||
260 | { | 253 | { |
261 | TextureSent(sender); | 254 | TextureSent(sender); |
255 | |||
256 | sender.Cancel = false; | ||
262 | } | 257 | } |
263 | else | 258 | else |
264 | { | 259 | { |
265 | m_queueSenders.Enqueue(sender); | 260 | bool finished = sender.SendTexturePacket(); |
261 | if (finished) | ||
262 | { | ||
263 | TextureSent(sender); | ||
264 | } | ||
265 | else | ||
266 | { | ||
267 | m_queueSenders.Enqueue(sender); | ||
268 | } | ||
266 | } | 269 | } |
267 | } | ||
268 | 270 | ||
269 | // Make sure that any sender we currently have can get garbage collected | 271 | // Make sure that any sender we currently have can get garbage collected |
270 | sender = null; | 272 | sender = null; |
271 | 273 | ||
272 | //m_log.InfoFormat("[TEXTURE] Texture sender queue size: {0}", m_queueSenders.Count()); | 274 | //m_log.InfoFormat("[TEXTURE] Texture sender queue size: {0}", m_queueSenders.Count()); |
275 | } | ||
276 | catch(Exception e) | ||
277 | { | ||
278 | m_log.ErrorFormat( | ||
279 | "[TEXTURE]: Texture send thread caught exception. The texture send was aborted. Exception is {0}", e); | ||
280 | } | ||
273 | } | 281 | } |
274 | } | 282 | // } |
275 | catch (Exception e) | 283 | // catch (Exception e) |
276 | { | 284 | // { |
277 | // TODO: Let users in the sim and those entering it and possibly an external watchdog know what has happened | 285 | // // TODO: Let users in the sim and those entering it and possibly an external watchdog know what has happened |
278 | m_log.ErrorFormat( | 286 | // m_log.ErrorFormat( |
279 | "[TEXTURE]: Texture send thread terminating with exception. PLEASE REBOOT YOUR SIM - TEXTURES WILL NOT BE AVAILABLE UNTIL YOU DO. Exception is {0}", | 287 | // "[TEXTURE]: Texture send thread terminating with exception. PLEASE REBOOT YOUR SIM - TEXTURES WILL NOT BE AVAILABLE UNTIL YOU DO. Exception is {0}", |
280 | e); | 288 | // e); |
281 | } | 289 | // } |
282 | } | 290 | } |
283 | 291 | ||
284 | /// <summary> | 292 | /// <summary> |
diff --git a/OpenSim/Region/Environment/Modules/Agent/TextureDownload/TextureNotFoundSender.cs b/OpenSim/Region/Environment/Modules/Agent/TextureDownload/TextureNotFoundSender.cs index c064064..044ee76 100644 --- a/OpenSim/Region/Environment/Modules/Agent/TextureDownload/TextureNotFoundSender.cs +++ b/OpenSim/Region/Environment/Modules/Agent/TextureDownload/TextureNotFoundSender.cs | |||
@@ -28,7 +28,6 @@ | |||
28 | using System.Reflection; | 28 | using System.Reflection; |
29 | using log4net; | 29 | using log4net; |
30 | using OpenMetaverse; | 30 | using OpenMetaverse; |
31 | using OpenMetaverse.Packets; | ||
32 | using OpenSim.Framework; | 31 | using OpenSim.Framework; |
33 | using OpenSim.Region.Environment.Interfaces; | 32 | using OpenSim.Region.Environment.Interfaces; |
34 | 33 | ||
diff --git a/OpenSim/Region/Environment/Modules/Agent/TextureDownload/UserTextureDownloadService.cs b/OpenSim/Region/Environment/Modules/Agent/TextureDownload/UserTextureDownloadService.cs index d6c9877..aab4ad0 100644 --- a/OpenSim/Region/Environment/Modules/Agent/TextureDownload/UserTextureDownloadService.cs +++ b/OpenSim/Region/Environment/Modules/Agent/TextureDownload/UserTextureDownloadService.cs | |||
@@ -56,11 +56,10 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureDownload | |||
56 | /// <summary> | 56 | /// <summary> |
57 | /// We will allow the client to request the same texture n times before dropping further requests | 57 | /// We will allow the client to request the same texture n times before dropping further requests |
58 | /// | 58 | /// |
59 | /// This number includes repeated requests for the same texture at different resolutions (which we don't | 59 | /// This number contains repeated requests for the same texture at different resolutions (which |
60 | /// currently handle properly as far as I know). However, this situation should be handled in a more | 60 | /// are handled since r7368). However, this situation should be handled in a more sophisticated way. |
61 | /// sophisticated way. | ||
62 | /// </summary> | 61 | /// </summary> |
63 | private static readonly int MAX_ALLOWED_TEXTURE_REQUESTS = 5; | 62 | private static readonly int MAX_ALLOWED_TEXTURE_REQUESTS = 15; |
64 | 63 | ||
65 | /// <summary> | 64 | /// <summary> |
66 | /// XXX Also going to limit requests for found textures. | 65 | /// XXX Also going to limit requests for found textures. |
@@ -149,7 +148,7 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureDownload | |||
149 | 148 | ||
150 | m_scene.AddPendingDownloads(1); | 149 | m_scene.AddPendingDownloads(1); |
151 | 150 | ||
152 | TextureSender.TextureSender requestHandler = new TextureSender.TextureSender(m_client, e.DiscardLevel, e.PacketNumber); | 151 | TextureSender.TextureSender requestHandler = new TextureSender.TextureSender(m_client, e.DiscardLevel, e.PacketNumber, e.Priority); |
153 | m_textureSenders.Add(e.RequestedAssetID, requestHandler); | 152 | m_textureSenders.Add(e.RequestedAssetID, requestHandler); |
154 | 153 | ||
155 | m_scene.AssetCache.GetAsset(e.RequestedAssetID, TextureCallback, true); | 154 | m_scene.AssetCache.GetAsset(e.RequestedAssetID, TextureCallback, true); |
diff --git a/OpenSim/Region/Environment/Modules/Agent/TextureSender/Tests/TextureSenderTests.cs b/OpenSim/Region/Environment/Modules/Agent/TextureSender/Tests/TextureSenderTests.cs index 4049dfc..cff215b 100644 --- a/OpenSim/Region/Environment/Modules/Agent/TextureSender/Tests/TextureSenderTests.cs +++ b/OpenSim/Region/Environment/Modules/Agent/TextureSender/Tests/TextureSenderTests.cs | |||
@@ -53,7 +53,7 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureSender | |||
53 | agent.startpos = Vector3.Zero; | 53 | agent.startpos = Vector3.Zero; |
54 | agent.CapsPath = "http://wibble.com"; | 54 | agent.CapsPath = "http://wibble.com"; |
55 | 55 | ||
56 | new TextureSender(new TestClient(agent), 0, 0); | 56 | new TextureSender(new TestClient(agent), 0, 0, 1.0f); |
57 | } | 57 | } |
58 | } | 58 | } |
59 | } \ No newline at end of file | 59 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Environment/Modules/Agent/TextureSender/TextureSender.cs b/OpenSim/Region/Environment/Modules/Agent/TextureSender/TextureSender.cs index 57129dd..0e34271 100644 --- a/OpenSim/Region/Environment/Modules/Agent/TextureSender/TextureSender.cs +++ b/OpenSim/Region/Environment/Modules/Agent/TextureSender/TextureSender.cs | |||
@@ -27,106 +27,188 @@ | |||
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Reflection; | 29 | using System.Reflection; |
30 | using OpenMetaverse.Packets; | ||
31 | using log4net; | 30 | using log4net; |
32 | using OpenSim.Framework; | 31 | using OpenSim.Framework; |
33 | using OpenSim.Region.Environment.Interfaces; | 32 | using OpenSim.Region.Environment.Interfaces; |
34 | 33 | ||
35 | namespace OpenSim.Region.Environment.Modules.Agent.TextureSender | 34 | namespace OpenSim.Region.Environment.Modules.Agent.TextureSender |
36 | { | 35 | { |
37 | /// <summary> | 36 | public class ImageDownload |
38 | /// A TextureSender handles the process of receiving a texture requested by the client from the | ||
39 | /// AssetCache, and then sending that texture back to the client. | ||
40 | /// </summary> | ||
41 | public class TextureSender : ITextureSender | ||
42 | { | 37 | { |
43 | private static readonly ILog m_log | 38 | public const int FIRST_IMAGE_PACKET_SIZE = 600; |
44 | = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 39 | public const int IMAGE_PACKET_SIZE = 1000; |
45 | 40 | ||
46 | /// <summary> | 41 | public OpenMetaverse.AssetTexture Texture; |
47 | /// Records the number of times texture send has been called. | 42 | public int DiscardLevel; |
48 | /// </summary> | 43 | public float Priority; |
49 | public int counter = 0; | 44 | public int CurrentPacket; |
45 | public int StopPacket; | ||
50 | 46 | ||
51 | public bool ImageLoaded = false; | 47 | public ImageDownload(OpenMetaverse.AssetTexture texture, int discardLevel, float priority, int packet) |
48 | { | ||
49 | Texture = texture; | ||
50 | Update(discardLevel, priority, packet); | ||
51 | } | ||
52 | 52 | ||
53 | /// <summary> | 53 | /// <summary> |
54 | /// Holds the texture asset to send. | 54 | /// Updates an image transfer with new information and recalculates |
55 | /// offsets | ||
55 | /// </summary> | 56 | /// </summary> |
56 | private AssetBase m_asset; | 57 | /// <param name="discardLevel">New requested discard level</param> |
58 | /// <param name="priority">New requested priority</param> | ||
59 | /// <param name="packet">New requested packet offset</param> | ||
60 | public void Update(int discardLevel, float priority, int packet) | ||
61 | { | ||
62 | Priority = priority; | ||
63 | DiscardLevel = Clamp(discardLevel, 0, Texture.LayerInfo.Length - 1); | ||
64 | StopPacket = GetPacketForBytePosition(Texture.LayerInfo[(Texture.LayerInfo.Length - 1) - DiscardLevel].End); | ||
65 | CurrentPacket = Clamp(packet, 1, TexturePacketCount()); | ||
66 | } | ||
57 | 67 | ||
58 | //public UUID assetID { get { return m_asset.FullID; } } | 68 | /// <summary> |
69 | /// Returns the total number of packets needed to transfer this texture, | ||
70 | /// including the first packet of size FIRST_IMAGE_PACKET_SIZE | ||
71 | /// </summary> | ||
72 | /// <returns>Total number of packets needed to transfer this texture</returns> | ||
73 | public int TexturePacketCount() | ||
74 | { | ||
75 | return ((Texture.AssetData.Length - FIRST_IMAGE_PACKET_SIZE + IMAGE_PACKET_SIZE - 1) / IMAGE_PACKET_SIZE) + 1; | ||
76 | } | ||
59 | 77 | ||
60 | // private bool m_cancel = false; | 78 | /// <summary> |
79 | /// Returns the current byte offset for this transfer, calculated from | ||
80 | /// the CurrentPacket | ||
81 | /// </summary> | ||
82 | /// <returns>Current byte offset for this transfer</returns> | ||
83 | public int CurrentBytePosition() | ||
84 | { | ||
85 | return FIRST_IMAGE_PACKET_SIZE + (CurrentPacket - 1) * IMAGE_PACKET_SIZE; | ||
86 | } | ||
61 | 87 | ||
62 | // See ITextureSender | 88 | /// <summary> |
89 | /// Returns the size, in bytes, of the last packet. This will be somewhere | ||
90 | /// between 1 and IMAGE_PACKET_SIZE bytes | ||
91 | /// </summary> | ||
92 | /// <returns>Size of the last packet in the transfer</returns> | ||
93 | public int LastPacketSize() | ||
94 | { | ||
95 | return Texture.AssetData.Length - (FIRST_IMAGE_PACKET_SIZE + ((TexturePacketCount() - 2) * IMAGE_PACKET_SIZE)); | ||
96 | } | ||
63 | 97 | ||
64 | // private bool m_sending = false; | 98 | /// <summary> |
99 | /// Find the packet number that contains a given byte position | ||
100 | /// </summary> | ||
101 | /// <param name="bytePosition">Byte position</param> | ||
102 | /// <returns>Packet number that contains the given byte position</returns> | ||
103 | int GetPacketForBytePosition(int bytePosition) | ||
104 | { | ||
105 | return ((bytePosition - FIRST_IMAGE_PACKET_SIZE + IMAGE_PACKET_SIZE - 1) / IMAGE_PACKET_SIZE); | ||
106 | } | ||
65 | 107 | ||
66 | /// <summary> | 108 | /// <summary> |
67 | /// This is actually the number of extra packets required to send the texture data! We always assume | 109 | /// Clamp a given value between a range |
68 | /// at least one is required. | ||
69 | /// </summary> | 110 | /// </summary> |
70 | private int NumPackets = 0; | 111 | /// <param name="value">Value to clamp</param> |
112 | /// <param name="min">Minimum allowable value</param> | ||
113 | /// <param name="max">Maximum allowable value</param> | ||
114 | /// <returns>A value inclusively between lower and upper</returns> | ||
115 | static int Clamp(int value, int min, int max) | ||
116 | { | ||
117 | // First we check to see if we're greater than the max | ||
118 | value = (value > max) ? max : value; | ||
119 | |||
120 | // Then we check to see if we're less than the min. | ||
121 | value = (value < min) ? min : value; | ||
122 | |||
123 | // There's no check to see if min > max. | ||
124 | return value; | ||
125 | } | ||
126 | } | ||
127 | |||
128 | /// <summary> | ||
129 | /// A TextureSender handles the process of receiving a texture requested by the client from the | ||
130 | /// AssetCache, and then sending that texture back to the client. | ||
131 | /// </summary> | ||
132 | public class TextureSender : ITextureSender | ||
133 | { | ||
134 | private static readonly ILog m_log | ||
135 | = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
136 | |||
137 | public bool ImageLoaded = false; | ||
71 | 138 | ||
72 | /// <summary> | 139 | /// <summary> |
73 | /// Holds the packet number to send next. In this case, each packet is 1000 bytes long and starts | 140 | /// Holds the texture asset to send. |
74 | /// at the 600th byte (0th indexed). | ||
75 | /// </summary> | 141 | /// </summary> |
76 | private int PacketCounter = 0; | 142 | private AssetBase m_asset; |
143 | private bool m_cancel = false; | ||
144 | private bool m_sending = false; | ||
145 | private bool sendFirstPacket = false; | ||
146 | private int initialDiscardLevel = 0; | ||
147 | private int initialPacketNum = 0; | ||
148 | private float initialPriority = 0.0f; | ||
77 | 149 | ||
78 | private int RequestedDiscardLevel = -1; | 150 | private ImageDownload download; |
79 | private IClientAPI RequestUser; | 151 | private IClientAPI RequestUser; |
80 | private uint StartPacketNumber = 0; | ||
81 | 152 | ||
82 | public TextureSender(IClientAPI client, int discardLevel, uint packetNumber) | 153 | public TextureSender(IClientAPI client, int discardLevel, uint packetNumber, float priority) |
83 | { | 154 | { |
84 | RequestUser = client; | 155 | RequestUser = client; |
85 | RequestedDiscardLevel = discardLevel; | 156 | initialDiscardLevel = discardLevel; |
86 | StartPacketNumber = packetNumber; | 157 | initialPacketNum = (int)packetNumber; |
158 | initialPriority = priority; | ||
87 | } | 159 | } |
88 | 160 | ||
89 | #region ITextureSender Members | 161 | #region ITextureSender Members |
90 | 162 | ||
91 | public bool Cancel | 163 | public bool Cancel |
92 | { | 164 | { |
93 | get { return false; } | 165 | get { return m_cancel; } |
94 | set | 166 | set { m_cancel = value; } |
95 | { | ||
96 | // m_cancel = value; | ||
97 | } | ||
98 | } | 167 | } |
99 | 168 | ||
100 | public bool Sending | 169 | public bool Sending |
101 | { | 170 | { |
102 | get { return false; } | 171 | get { return m_sending; } |
103 | set | 172 | set { m_sending = value; } |
104 | { | ||
105 | // m_sending = value; | ||
106 | } | ||
107 | } | 173 | } |
108 | 174 | ||
109 | // See ITextureSender | 175 | // See ITextureSender |
110 | public void UpdateRequest(int discardLevel, uint packetNumber) | 176 | public void UpdateRequest(int discardLevel, uint packetNumber) |
111 | { | 177 | { |
112 | RequestedDiscardLevel = discardLevel; | 178 | if (download == null) |
113 | StartPacketNumber = packetNumber; | 179 | return; |
114 | PacketCounter = (int) StartPacketNumber; | 180 | |
181 | lock (download) | ||
182 | { | ||
183 | if (discardLevel < download.DiscardLevel) | ||
184 | m_log.DebugFormat("Image download {0} is changing from DiscardLevel {1} to {2}", | ||
185 | m_asset.FullID, download.DiscardLevel, discardLevel); | ||
186 | |||
187 | if (packetNumber != download.CurrentPacket) | ||
188 | m_log.DebugFormat("Image download {0} is changing from Packet {1} to {2}", | ||
189 | m_asset.FullID, download.CurrentPacket, packetNumber); | ||
190 | |||
191 | download.Update(discardLevel, download.Priority, (int)packetNumber); | ||
192 | |||
193 | sendFirstPacket = true; | ||
194 | } | ||
115 | } | 195 | } |
116 | 196 | ||
117 | // See ITextureSender | 197 | // See ITextureSender |
118 | public bool SendTexturePacket() | 198 | public bool SendTexturePacket() |
119 | { | 199 | { |
120 | //m_log.DebugFormat("[TEXTURE SENDER]: Sending packet for {0}", m_asset.FullID); | 200 | if (download != null && !m_cancel && (sendFirstPacket || download.CurrentPacket <= download.StopPacket)) |
121 | 201 | { | |
122 | SendPacket(); | 202 | SendPacket(); |
123 | counter++; | 203 | return false; |
124 | if ((NumPackets == 0) || (RequestedDiscardLevel == -1) || (PacketCounter > NumPackets) || | 204 | } |
125 | ((RequestedDiscardLevel > 0) && (counter > 50 + (NumPackets / (RequestedDiscardLevel + 1))))) | 205 | else |
126 | { | 206 | { |
207 | m_sending = false; | ||
208 | m_cancel = true; | ||
209 | sendFirstPacket = false; | ||
127 | return true; | 210 | return true; |
128 | } | 211 | } |
129 | return false; | ||
130 | } | 212 | } |
131 | 213 | ||
132 | #endregion | 214 | #endregion |
@@ -138,76 +220,101 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureSender | |||
138 | public void TextureReceived(AssetBase asset) | 220 | public void TextureReceived(AssetBase asset) |
139 | { | 221 | { |
140 | m_asset = asset; | 222 | m_asset = asset; |
141 | NumPackets = CalculateNumPackets(asset.Data.Length); | ||
142 | PacketCounter = (int) StartPacketNumber; | ||
143 | ImageLoaded = true; | ||
144 | } | ||
145 | 223 | ||
146 | /// <summary> | 224 | try |
147 | /// Sends a texture packet to the client. | ||
148 | /// </summary> | ||
149 | private void SendPacket() | ||
150 | { | ||
151 | if (PacketCounter <= NumPackets) | ||
152 | { | 225 | { |
153 | if (PacketCounter == 0) | 226 | OpenMetaverse.AssetTexture texture = new OpenMetaverse.AssetTexture(m_asset.FullID, m_asset.Data); |
227 | if (texture.DecodeLayerBoundaries()) | ||
154 | { | 228 | { |
155 | if (NumPackets == 0) | 229 | bool sane = true; |
230 | |||
231 | // Sanity check all of the layers | ||
232 | for (int i = 0; i < texture.LayerInfo.Length; i++) | ||
156 | { | 233 | { |
157 | RequestUser.SendImageFirstPart(1, m_asset.FullID, (uint)m_asset.Data.Length, m_asset.Data, 2); | 234 | if (texture.LayerInfo[i].End > texture.AssetData.Length) |
158 | PacketCounter++; | 235 | { |
236 | sane = false; | ||
237 | break; | ||
238 | } | ||
239 | } | ||
240 | |||
241 | if (sane) | ||
242 | { | ||
243 | download = new ImageDownload(texture, initialDiscardLevel, initialPriority, initialPacketNum); | ||
244 | ImageLoaded = true; | ||
245 | m_sending = true; | ||
246 | m_cancel = false; | ||
247 | sendFirstPacket = true; | ||
248 | return; | ||
159 | } | 249 | } |
160 | else | 250 | else |
161 | { | 251 | { |
162 | byte[] ImageData1 = new byte[600]; | 252 | m_log.Error("JPEG2000 texture decoding succeeded, but sanity check failed for " + |
163 | Array.Copy(m_asset.Data, 0, ImageData1, 0, 600); | 253 | m_asset.FullID.ToString()); |
164 | |||
165 | RequestUser.SendImageFirstPart( | ||
166 | (ushort)(NumPackets), m_asset.FullID, (uint)m_asset.Data.Length, ImageData1, 2); | ||
167 | PacketCounter++; | ||
168 | } | 254 | } |
169 | } | 255 | } |
170 | else | 256 | else |
171 | { | 257 | { |
172 | int size = m_asset.Data.Length - 600 - (1000 * (PacketCounter - 1)); | 258 | m_log.Error("JPEG2000 texture decoding failed for " + m_asset.FullID.ToString()); |
173 | if (size > 1000) size = 1000; | ||
174 | byte[] imageData = new byte[size]; | ||
175 | try | ||
176 | { | ||
177 | Array.Copy(m_asset.Data, 600 + (1000 * (PacketCounter - 1)), imageData, 0, size); | ||
178 | } | ||
179 | catch (ArgumentOutOfRangeException) | ||
180 | { | ||
181 | m_log.Error("[TEXTURE SENDER]: Unable to separate texture into multiple packets: Array bounds failure on asset:" + | ||
182 | m_asset.FullID.ToString()); | ||
183 | return; | ||
184 | } | ||
185 | |||
186 | RequestUser.SendImageNextPart((ushort)PacketCounter, m_asset.FullID, imageData); | ||
187 | PacketCounter++; | ||
188 | } | 259 | } |
189 | } | 260 | } |
261 | catch (Exception ex) | ||
262 | { | ||
263 | m_log.Error("JPEG2000 texture decoding threw an exception for " + m_asset.FullID.ToString(), ex); | ||
264 | } | ||
265 | |||
266 | ImageLoaded = false; | ||
267 | m_sending = false; | ||
268 | m_cancel = true; | ||
190 | } | 269 | } |
191 | 270 | ||
192 | /// <summary> | 271 | /// <summary> |
193 | /// Calculate the number of packets that will be required to send the texture loaded into this sender | 272 | /// Sends a texture packet to the client. |
194 | /// This is actually the number of 1000 byte packets not including an initial 600 byte packet... | ||
195 | /// </summary> | 273 | /// </summary> |
196 | /// <param name="length"></param> | 274 | private void SendPacket() |
197 | /// <returns></returns> | ||
198 | private int CalculateNumPackets(int length) | ||
199 | { | 275 | { |
200 | int numPackets = 0; | 276 | lock (download) |
201 | |||
202 | if (length > 600) | ||
203 | { | 277 | { |
204 | //over 600 bytes so split up file | 278 | if (sendFirstPacket) |
205 | int restData = (length - 600); | 279 | { |
206 | int restPackets = ((restData + 999) / 1000); | 280 | sendFirstPacket = false; |
207 | numPackets = restPackets; | ||
208 | } | ||
209 | 281 | ||
210 | return numPackets; | 282 | if (m_asset.Data.Length <= ImageDownload.FIRST_IMAGE_PACKET_SIZE) |
283 | { | ||
284 | RequestUser.SendImageFirstPart(1, m_asset.FullID, (uint)m_asset.Data.Length, m_asset.Data, 2); | ||
285 | return; | ||
286 | } | ||
287 | else | ||
288 | { | ||
289 | byte[] firstImageData = new byte[ImageDownload.FIRST_IMAGE_PACKET_SIZE]; | ||
290 | try { Buffer.BlockCopy(m_asset.Data, 0, firstImageData, 0, ImageDownload.FIRST_IMAGE_PACKET_SIZE); } | ||
291 | catch (Exception) | ||
292 | { | ||
293 | m_log.Error("Texture data copy failed on first packet for " + m_asset.FullID.ToString()); | ||
294 | m_cancel = true; | ||
295 | m_sending = false; | ||
296 | return; | ||
297 | } | ||
298 | RequestUser.SendImageFirstPart((ushort)download.TexturePacketCount(), m_asset.FullID, (uint)m_asset.Data.Length, firstImageData, 2); | ||
299 | } | ||
300 | } | ||
301 | |||
302 | int imagePacketSize = (download.CurrentPacket == download.TexturePacketCount() - 1) ? | ||
303 | download.LastPacketSize() : ImageDownload.IMAGE_PACKET_SIZE; | ||
304 | |||
305 | byte[] imageData = new byte[imagePacketSize]; | ||
306 | try { Buffer.BlockCopy(m_asset.Data, download.CurrentBytePosition(), imageData, 0, imagePacketSize); } | ||
307 | catch (Exception) | ||
308 | { | ||
309 | m_log.Error("Texture data copy failed for " + m_asset.FullID.ToString()); | ||
310 | m_cancel = true; | ||
311 | m_sending = false; | ||
312 | return; | ||
313 | } | ||
314 | |||
315 | RequestUser.SendImageNextPart((ushort)download.CurrentPacket, m_asset.FullID, imageData); | ||
316 | ++download.CurrentPacket; | ||
317 | } | ||
211 | } | 318 | } |
212 | } | 319 | } |
213 | } | 320 | } |
diff --git a/OpenSim/Region/Environment/Modules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/Environment/Modules/Avatar/Friends/FriendsModule.cs index 580982d..ed77b2e 100644 --- a/OpenSim/Region/Environment/Modules/Avatar/Friends/FriendsModule.cs +++ b/OpenSim/Region/Environment/Modules/Avatar/Friends/FriendsModule.cs | |||
@@ -30,7 +30,6 @@ using System.Collections; | |||
30 | using System.Collections.Generic; | 30 | using System.Collections.Generic; |
31 | using System.Reflection; | 31 | using System.Reflection; |
32 | using OpenMetaverse; | 32 | using OpenMetaverse; |
33 | using OpenMetaverse.Packets; | ||
34 | using log4net; | 33 | using log4net; |
35 | using Nini.Config; | 34 | using Nini.Config; |
36 | using Nwc.XmlRpc; | 35 | using Nwc.XmlRpc; |
diff --git a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs index 1e26c91..bcc0d19 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs | |||
@@ -31,7 +31,6 @@ using System.Reflection; | |||
31 | using System.Text; | 31 | using System.Text; |
32 | using System.Timers; | 32 | using System.Timers; |
33 | using OpenMetaverse; | 33 | using OpenMetaverse; |
34 | using OpenMetaverse.Packets; | ||
35 | using log4net; | 34 | using log4net; |
36 | using OpenSim.Framework; | 35 | using OpenSim.Framework; |
37 | using OpenSim.Framework.Communications.Cache; | 36 | using OpenSim.Framework.Communications.Cache; |
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index 340dd39..3431309 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | |||
@@ -544,11 +544,21 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
544 | Evidence baseEvidence = AppDomain.CurrentDomain.Evidence; | 544 | Evidence baseEvidence = AppDomain.CurrentDomain.Evidence; |
545 | Evidence evidence = new Evidence(baseEvidence); | 545 | Evidence evidence = new Evidence(baseEvidence); |
546 | 546 | ||
547 | m_AppDomains[appDomain] = | 547 | AppDomain sandbox = |
548 | AppDomain.CreateDomain( | 548 | AppDomain.CreateDomain( |
549 | m_Scene.RegionInfo.RegionID.ToString(), | 549 | m_Scene.RegionInfo.RegionID.ToString(), |
550 | evidence, appSetup); | 550 | evidence, appSetup); |
551 | 551 | ||
552 | PolicyLevel sandboxPolicy = PolicyLevel.CreateAppDomainLevel(); | ||
553 | AllMembershipCondition sandboxMembershipCondition = new AllMembershipCondition(); | ||
554 | PermissionSet sandboxPermissionSet = sandboxPolicy.GetNamedPermissionSet("Internet"); | ||
555 | PolicyStatement sandboxPolicyStatement = new PolicyStatement(sandboxPermissionSet); | ||
556 | CodeGroup sandboxCodeGroup = new UnionCodeGroup(sandboxMembershipCondition, sandboxPolicyStatement); | ||
557 | sandboxPolicy.RootCodeGroup = sandboxCodeGroup; | ||
558 | sandbox.SetAppDomainPolicy(sandboxPolicy); | ||
559 | |||
560 | m_AppDomains[appDomain] = sandbox; | ||
561 | |||
552 | m_AppDomains[appDomain].AssemblyResolve += | 562 | m_AppDomains[appDomain].AssemblyResolve += |
553 | new ResolveEventHandler( | 563 | new ResolveEventHandler( |
554 | AssemblyResolver.OnAssemblyResolve); | 564 | AssemblyResolver.OnAssemblyResolve); |