diff options
Diffstat (limited to 'OpenSim/Region')
10 files changed, 637 insertions, 28 deletions
diff --git a/OpenSim/Region/Application/OpenSimBase.cs b/OpenSim/Region/Application/OpenSimBase.cs index 4592c31..3df3a1c 100644 --- a/OpenSim/Region/Application/OpenSimBase.cs +++ b/OpenSim/Region/Application/OpenSimBase.cs | |||
@@ -459,7 +459,8 @@ namespace OpenSim | |||
459 | 459 | ||
460 | scene.DeleteAllSceneObjects(); | 460 | scene.DeleteAllSceneObjects(); |
461 | m_sceneManager.CloseScene(scene); | 461 | m_sceneManager.CloseScene(scene); |
462 | 462 | ShutdownClientServer(scene.RegionInfo); | |
463 | |||
463 | if (!cleanup) | 464 | if (!cleanup) |
464 | return; | 465 | return; |
465 | 466 | ||
@@ -519,7 +520,7 @@ namespace OpenSim | |||
519 | } | 520 | } |
520 | 521 | ||
521 | m_sceneManager.CloseScene(scene); | 522 | m_sceneManager.CloseScene(scene); |
522 | 523 | ShutdownClientServer(scene.RegionInfo); | |
523 | } | 524 | } |
524 | 525 | ||
525 | /// <summary> | 526 | /// <summary> |
@@ -653,12 +654,10 @@ namespace OpenSim | |||
653 | storageManager, m_moduleLoader, false, m_configSettings.PhysicalPrim, | 654 | storageManager, m_moduleLoader, false, m_configSettings.PhysicalPrim, |
654 | m_configSettings.See_into_region_from_neighbor, m_config.Source, m_version); | 655 | m_configSettings.See_into_region_from_neighbor, m_config.Source, m_version); |
655 | } | 656 | } |
656 | 657 | ||
657 | public void handleRestartRegion(RegionInfo whichRegion) | 658 | protected void ShutdownClientServer(RegionInfo whichRegion) |
658 | { | 659 | { |
659 | m_log.Info("[OPENSIM]: Got restart signal from SceneManager"); | 660 | // Close and remove the clientserver for a region |
660 | |||
661 | // Shutting down the client server | ||
662 | bool foundClientServer = false; | 661 | bool foundClientServer = false; |
663 | int clientServerElement = 0; | 662 | int clientServerElement = 0; |
664 | Location location = new Location(whichRegion.RegionHandle); | 663 | Location location = new Location(whichRegion.RegionHandle); |
@@ -678,6 +677,13 @@ namespace OpenSim | |||
678 | m_clientServers[clientServerElement].NetworkStop(); | 677 | m_clientServers[clientServerElement].NetworkStop(); |
679 | m_clientServers.RemoveAt(clientServerElement); | 678 | m_clientServers.RemoveAt(clientServerElement); |
680 | } | 679 | } |
680 | } | ||
681 | |||
682 | public void handleRestartRegion(RegionInfo whichRegion) | ||
683 | { | ||
684 | m_log.Info("[OPENSIM]: Got restart signal from SceneManager"); | ||
685 | |||
686 | ShutdownClientServer(whichRegion); | ||
681 | IScene scene; | 687 | IScene scene; |
682 | CreateRegion(whichRegion, true, out scene); | 688 | CreateRegion(whichRegion, true, out scene); |
683 | } | 689 | } |
diff --git a/OpenSim/Region/ClientStack/LindenUDP/J2KImage.cs b/OpenSim/Region/ClientStack/LindenUDP/J2KImage.cs index 2f1face..5877779 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/J2KImage.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/J2KImage.cs | |||
@@ -74,6 +74,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
74 | 74 | ||
75 | public bool SendPackets(LLClientView client, int maxpack) | 75 | public bool SendPackets(LLClientView client, int maxpack) |
76 | { | 76 | { |
77 | if (client == null) | ||
78 | return false; | ||
79 | |||
77 | if (m_currentPacket <= m_stopPacket) | 80 | if (m_currentPacket <= m_stopPacket) |
78 | { | 81 | { |
79 | int count = 0; | 82 | int count = 0; |
@@ -202,6 +205,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
202 | 205 | ||
203 | private bool SendFirstPacket(LLClientView client) | 206 | private bool SendFirstPacket(LLClientView client) |
204 | { | 207 | { |
208 | if (client == null) | ||
209 | return false; | ||
210 | |||
205 | if (m_asset == null) | 211 | if (m_asset == null) |
206 | { | 212 | { |
207 | m_log.Warn("[J2KIMAGE]: Sending ImageNotInDatabase for texture " + TextureID); | 213 | m_log.Warn("[J2KIMAGE]: Sending ImageNotInDatabase for texture " + TextureID); |
@@ -234,6 +240,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
234 | 240 | ||
235 | private bool SendPacket(LLClientView client) | 241 | private bool SendPacket(LLClientView client) |
236 | { | 242 | { |
243 | if (client == null) | ||
244 | return false; | ||
245 | |||
237 | bool complete = false; | 246 | bool complete = false; |
238 | int imagePacketSize = ((int)m_currentPacket == (TexturePacketCount())) ? LastPacketSize() : IMAGE_PACKET_SIZE; | 247 | int imagePacketSize = ((int)m_currentPacket == (TexturePacketCount())) ? LastPacketSize() : IMAGE_PACKET_SIZE; |
239 | 248 | ||
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLUDPClientCollection.cs b/OpenSim/Region/ClientStack/LindenUDP/LLUDPClientCollection.cs index f6ccf01..dbb9861 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLUDPClientCollection.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLUDPClientCollection.cs | |||
@@ -224,16 +224,16 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
224 | 224 | ||
225 | ////return success; | 225 | ////return success; |
226 | 226 | ||
227 | //lock (m_sync) | 227 | lock (m_sync) |
228 | // return Dictionary1.TryGetValue(key, out value); | 228 | return Dictionary1.TryGetValue(key, out value); |
229 | 229 | ||
230 | try | 230 | //try |
231 | { | 231 | //{ |
232 | return Dictionary1.TryGetValue(key, out value); | 232 | // return Dictionary1.TryGetValue(key, out value); |
233 | } | 233 | //} |
234 | catch { } | 234 | //catch { } |
235 | value = null; | 235 | //value = null; |
236 | return false; | 236 | //return false; |
237 | } | 237 | } |
238 | 238 | ||
239 | public bool TryGetValue(IPEndPoint key, out LLUDPClient value) | 239 | public bool TryGetValue(IPEndPoint key, out LLUDPClient value) |
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs index 2c5ad85..0390277 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs | |||
@@ -87,7 +87,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
87 | /// The LLUDP server for a region. This handles incoming and outgoing | 87 | /// The LLUDP server for a region. This handles incoming and outgoing |
88 | /// packets for all UDP connections to the region | 88 | /// packets for all UDP connections to the region |
89 | /// </summary> | 89 | /// </summary> |
90 | public class LLUDPServer : UDPBase | 90 | public class LLUDPServer : OpenSimUDPBase |
91 | { | 91 | { |
92 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 92 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
93 | 93 | ||
@@ -287,11 +287,15 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
287 | // instead | 287 | // instead |
288 | m_log.Info("[LLUDPSERVER]: Packet exceeded buffer size during zerocoding. Removing MSG_ZEROCODED flag"); | 288 | m_log.Info("[LLUDPSERVER]: Packet exceeded buffer size during zerocoding. Removing MSG_ZEROCODED flag"); |
289 | data[0] = (byte)(data[0] & ~Helpers.MSG_ZEROCODED); | 289 | data[0] = (byte)(data[0] & ~Helpers.MSG_ZEROCODED); |
290 | // | ||
291 | buffer = new UDPPacketBuffer(client.RemoteEndPoint, dataLength); | ||
292 | // | ||
290 | Buffer.BlockCopy(data, 0, buffer.Data, 0, dataLength); | 293 | Buffer.BlockCopy(data, 0, buffer.Data, 0, dataLength); |
291 | } | 294 | } |
292 | } | 295 | } |
293 | else | 296 | else |
294 | { | 297 | { |
298 | // ??? will it fit? | ||
295 | Buffer.BlockCopy(data, 0, buffer.Data, 0, dataLength); | 299 | Buffer.BlockCopy(data, 0, buffer.Data, 0, dataLength); |
296 | } | 300 | } |
297 | buffer.DataLength = dataLength; | 301 | buffer.DataLength = dataLength; |
diff --git a/OpenSim/Region/ClientStack/LindenUDP/OpenSimUDPBase.cs b/OpenSim/Region/ClientStack/LindenUDP/OpenSimUDPBase.cs new file mode 100644 index 0000000..43a68ec --- /dev/null +++ b/OpenSim/Region/ClientStack/LindenUDP/OpenSimUDPBase.cs | |||
@@ -0,0 +1,569 @@ | |||
1 | //--------- Modified Version ------------------- | ||
2 | ///* | ||
3 | // * Copyright (c) 2006, Clutch, Inc. | ||
4 | // * Original Author: Jeff Cesnik | ||
5 | // * All rights reserved. | ||
6 | // * | ||
7 | // * - Redistribution and use in source and binary forms, with or without | ||
8 | // * modification, are permitted provided that the following conditions are met: | ||
9 | // * | ||
10 | // * - Redistributions of source code must retain the above copyright notice, this | ||
11 | // * list of conditions and the following disclaimer. | ||
12 | // * - Neither the name of the openmetaverse.org nor the names | ||
13 | // * of its contributors may be used to endorse or promote products derived from | ||
14 | // * this software without specific prior written permission. | ||
15 | // * | ||
16 | // * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
17 | // * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
18 | // * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
19 | // * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE | ||
20 | // * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
21 | // * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
22 | // * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
23 | // * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
24 | // * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
25 | // * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
26 | // * POSSIBILITY OF SUCH DAMAGE. | ||
27 | // */ | ||
28 | |||
29 | using System; | ||
30 | using System.Net; | ||
31 | using System.Net.Sockets; | ||
32 | using System.Threading; | ||
33 | using OpenMetaverse; | ||
34 | |||
35 | //namespace OpenSim.Region.ClientStack.LindenUDP | ||
36 | //{ | ||
37 | // /// <summary> | ||
38 | // /// | ||
39 | // /// </summary> | ||
40 | // public abstract class OpenSimUDPBase | ||
41 | // { | ||
42 | // // these abstract methods must be implemented in a derived class to actually do | ||
43 | // // something with the packets that are sent and received. | ||
44 | // protected abstract void PacketReceived(UDPPacketBuffer buffer); | ||
45 | // protected abstract void PacketSent(UDPPacketBuffer buffer, int bytesSent); | ||
46 | |||
47 | // // the port to listen on | ||
48 | // internal int udpPort; | ||
49 | |||
50 | // // the UDP socket | ||
51 | // private Socket udpSocket; | ||
52 | |||
53 | // // the ReaderWriterLock is used solely for the purposes of shutdown (Stop()). | ||
54 | // // since there are potentially many "reader" threads in the internal .NET IOCP | ||
55 | // // thread pool, this is a cheaper synchronization primitive than using | ||
56 | // // a Mutex object. This allows many UDP socket "reads" concurrently - when | ||
57 | // // Stop() is called, it attempts to obtain a writer lock which will then | ||
58 | // // wait until all outstanding operations are completed before shutting down. | ||
59 | // // this avoids the problem of closing the socket with outstanding operations | ||
60 | // // and trying to catch the inevitable ObjectDisposedException. | ||
61 | // private ReaderWriterLock rwLock = new ReaderWriterLock(); | ||
62 | |||
63 | // // number of outstanding operations. This is a reference count | ||
64 | // // which we use to ensure that the threads exit cleanly. Note that | ||
65 | // // we need this because the threads will potentially still need to process | ||
66 | // // data even after the socket is closed. | ||
67 | // private int rwOperationCount = 0; | ||
68 | |||
69 | // // the all important shutdownFlag. This is synchronized through the ReaderWriterLock. | ||
70 | // private volatile bool shutdownFlag = true; | ||
71 | |||
72 | // // the remote endpoint to communicate with | ||
73 | // protected IPEndPoint remoteEndPoint = null; | ||
74 | |||
75 | |||
76 | // /// <summary> | ||
77 | // /// Initialize the UDP packet handler in server mode | ||
78 | // /// </summary> | ||
79 | // /// <param name="port">Port to listening for incoming UDP packets on</param> | ||
80 | // public OpenSimUDPBase(int port) | ||
81 | // { | ||
82 | // udpPort = port; | ||
83 | // } | ||
84 | |||
85 | // /// <summary> | ||
86 | // /// Initialize the UDP packet handler in client mode | ||
87 | // /// </summary> | ||
88 | // /// <param name="endPoint">Remote UDP server to connect to</param> | ||
89 | // public OpenSimUDPBase(IPEndPoint endPoint) | ||
90 | // { | ||
91 | // remoteEndPoint = endPoint; | ||
92 | // udpPort = 0; | ||
93 | // } | ||
94 | |||
95 | // /// <summary> | ||
96 | // /// | ||
97 | // /// </summary> | ||
98 | // public void Start() | ||
99 | // { | ||
100 | // if (shutdownFlag) | ||
101 | // { | ||
102 | // if (remoteEndPoint == null) | ||
103 | // { | ||
104 | // // Server mode | ||
105 | |||
106 | // // create and bind the socket | ||
107 | // IPEndPoint ipep = new IPEndPoint(Settings.BIND_ADDR, udpPort); | ||
108 | // udpSocket = new Socket( | ||
109 | // AddressFamily.InterNetwork, | ||
110 | // SocketType.Dgram, | ||
111 | // ProtocolType.Udp); | ||
112 | // udpSocket.Bind(ipep); | ||
113 | // } | ||
114 | // else | ||
115 | // { | ||
116 | // // Client mode | ||
117 | // IPEndPoint ipep = new IPEndPoint(Settings.BIND_ADDR, udpPort); | ||
118 | // udpSocket = new Socket( | ||
119 | // AddressFamily.InterNetwork, | ||
120 | // SocketType.Dgram, | ||
121 | // ProtocolType.Udp); | ||
122 | // udpSocket.Bind(ipep); | ||
123 | // //udpSocket.Connect(remoteEndPoint); | ||
124 | // } | ||
125 | |||
126 | // // we're not shutting down, we're starting up | ||
127 | // shutdownFlag = false; | ||
128 | |||
129 | // // kick off an async receive. The Start() method will return, the | ||
130 | // // actual receives will occur asynchronously and will be caught in | ||
131 | // // AsyncEndRecieve(). | ||
132 | // AsyncBeginReceive(); | ||
133 | // } | ||
134 | // } | ||
135 | |||
136 | // /// <summary> | ||
137 | // /// | ||
138 | // /// </summary> | ||
139 | // public void Stop() | ||
140 | // { | ||
141 | // if (!shutdownFlag) | ||
142 | // { | ||
143 | // // wait indefinitely for a writer lock. Once this is called, the .NET runtime | ||
144 | // // will deny any more reader locks, in effect blocking all other send/receive | ||
145 | // // threads. Once we have the lock, we set shutdownFlag to inform the other | ||
146 | // // threads that the socket is closed. | ||
147 | // rwLock.AcquireWriterLock(-1); | ||
148 | // shutdownFlag = true; | ||
149 | // udpSocket.Close(); | ||
150 | // rwLock.ReleaseWriterLock(); | ||
151 | |||
152 | // // wait for any pending operations to complete on other | ||
153 | // // threads before exiting. | ||
154 | // const int FORCE_STOP = 100; | ||
155 | // int i = 0; | ||
156 | // while (rwOperationCount > 0 && i < FORCE_STOP) | ||
157 | // { | ||
158 | // Thread.Sleep(10); | ||
159 | // ++i; | ||
160 | // } | ||
161 | |||
162 | // if (i >= FORCE_STOP) | ||
163 | // { | ||
164 | // Logger.Log("UDPBase.Stop() forced shutdown while waiting on pending operations", | ||
165 | // Helpers.LogLevel.Warning); | ||
166 | // } | ||
167 | // } | ||
168 | // } | ||
169 | |||
170 | // /// <summary> | ||
171 | // /// | ||
172 | // /// </summary> | ||
173 | // public bool IsRunning | ||
174 | // { | ||
175 | // get { return !shutdownFlag; } | ||
176 | // } | ||
177 | |||
178 | // private void AsyncBeginReceive() | ||
179 | // { | ||
180 | // // this method actually kicks off the async read on the socket. | ||
181 | // // we aquire a reader lock here to ensure that no other thread | ||
182 | // // is trying to set shutdownFlag and close the socket. | ||
183 | // rwLock.AcquireReaderLock(-1); | ||
184 | |||
185 | // if (!shutdownFlag) | ||
186 | // { | ||
187 | // // increment the count of pending operations | ||
188 | // Interlocked.Increment(ref rwOperationCount); | ||
189 | |||
190 | // // allocate a packet buffer | ||
191 | // //WrappedObject<UDPPacketBuffer> wrappedBuffer = Pool.CheckOut(); | ||
192 | // UDPPacketBuffer buf = new UDPPacketBuffer(); | ||
193 | |||
194 | // try | ||
195 | // { | ||
196 | // // kick off an async read | ||
197 | // udpSocket.BeginReceiveFrom( | ||
198 | // //wrappedBuffer.Instance.Data, | ||
199 | // buf.Data, | ||
200 | // 0, | ||
201 | // UDPPacketBuffer.BUFFER_SIZE, | ||
202 | // SocketFlags.None, | ||
203 | // //ref wrappedBuffer.Instance.RemoteEndPoint, | ||
204 | // ref buf.RemoteEndPoint, | ||
205 | // new AsyncCallback(AsyncEndReceive), | ||
206 | // //wrappedBuffer); | ||
207 | // buf); | ||
208 | // } | ||
209 | // catch (SocketException) | ||
210 | // { | ||
211 | // // something bad happened | ||
212 | // //Logger.Log( | ||
213 | // // "A SocketException occurred in UDPServer.AsyncBeginReceive()", | ||
214 | // // Helpers.LogLevel.Error, se); | ||
215 | |||
216 | // // an error occurred, therefore the operation is void. Decrement the reference count. | ||
217 | // Interlocked.Decrement(ref rwOperationCount); | ||
218 | // } | ||
219 | // } | ||
220 | |||
221 | // // we're done with the socket for now, release the reader lock. | ||
222 | // rwLock.ReleaseReaderLock(); | ||
223 | // } | ||
224 | |||
225 | // private void AsyncEndReceive(IAsyncResult iar) | ||
226 | // { | ||
227 | // // Asynchronous receive operations will complete here through the call | ||
228 | // // to AsyncBeginReceive | ||
229 | |||
230 | // // aquire a reader lock | ||
231 | // rwLock.AcquireReaderLock(-1); | ||
232 | |||
233 | // if (!shutdownFlag) | ||
234 | // { | ||
235 | // // get the buffer that was created in AsyncBeginReceive | ||
236 | // // this is the received data | ||
237 | // //WrappedObject<UDPPacketBuffer> wrappedBuffer = (WrappedObject<UDPPacketBuffer>)iar.AsyncState; | ||
238 | // //UDPPacketBuffer buffer = wrappedBuffer.Instance; | ||
239 | // UDPPacketBuffer buffer = (UDPPacketBuffer)iar.AsyncState; | ||
240 | |||
241 | // try | ||
242 | // { | ||
243 | // // get the length of data actually read from the socket, store it with the | ||
244 | // // buffer | ||
245 | // buffer.DataLength = udpSocket.EndReceiveFrom(iar, ref buffer.RemoteEndPoint); | ||
246 | |||
247 | // // this operation is now complete, decrement the reference count | ||
248 | // Interlocked.Decrement(ref rwOperationCount); | ||
249 | |||
250 | // // we're done with the socket, release the reader lock | ||
251 | // rwLock.ReleaseReaderLock(); | ||
252 | |||
253 | // // call the abstract method PacketReceived(), passing the buffer that | ||
254 | // // has just been filled from the socket read. | ||
255 | // PacketReceived(buffer); | ||
256 | // } | ||
257 | // catch (SocketException) | ||
258 | // { | ||
259 | // // an error occurred, therefore the operation is void. Decrement the reference count. | ||
260 | // Interlocked.Decrement(ref rwOperationCount); | ||
261 | |||
262 | // // we're done with the socket for now, release the reader lock. | ||
263 | // rwLock.ReleaseReaderLock(); | ||
264 | // } | ||
265 | // finally | ||
266 | // { | ||
267 | // // start another receive - this keeps the server going! | ||
268 | // AsyncBeginReceive(); | ||
269 | |||
270 | // //wrappedBuffer.Dispose(); | ||
271 | // } | ||
272 | // } | ||
273 | // else | ||
274 | // { | ||
275 | // // nothing bad happened, but we are done with the operation | ||
276 | // // decrement the reference count and release the reader lock | ||
277 | // Interlocked.Decrement(ref rwOperationCount); | ||
278 | // rwLock.ReleaseReaderLock(); | ||
279 | // } | ||
280 | // } | ||
281 | |||
282 | // public void AsyncBeginSend(UDPPacketBuffer buf) | ||
283 | // { | ||
284 | // rwLock.AcquireReaderLock(-1); | ||
285 | |||
286 | // if (!shutdownFlag) | ||
287 | // { | ||
288 | // try | ||
289 | // { | ||
290 | // Interlocked.Increment(ref rwOperationCount); | ||
291 | // udpSocket.BeginSendTo( | ||
292 | // buf.Data, | ||
293 | // 0, | ||
294 | // buf.DataLength, | ||
295 | // SocketFlags.None, | ||
296 | // buf.RemoteEndPoint, | ||
297 | // new AsyncCallback(AsyncEndSend), | ||
298 | // buf); | ||
299 | // } | ||
300 | // catch (SocketException) | ||
301 | // { | ||
302 | // //Logger.Log( | ||
303 | // // "A SocketException occurred in UDPServer.AsyncBeginSend()", | ||
304 | // // Helpers.LogLevel.Error, se); | ||
305 | // } | ||
306 | // } | ||
307 | |||
308 | // rwLock.ReleaseReaderLock(); | ||
309 | // } | ||
310 | |||
311 | // private void AsyncEndSend(IAsyncResult iar) | ||
312 | // { | ||
313 | // rwLock.AcquireReaderLock(-1); | ||
314 | |||
315 | // if (!shutdownFlag) | ||
316 | // { | ||
317 | // UDPPacketBuffer buffer = (UDPPacketBuffer)iar.AsyncState; | ||
318 | |||
319 | // try | ||
320 | // { | ||
321 | // int bytesSent = udpSocket.EndSendTo(iar); | ||
322 | |||
323 | // // note that call to the abstract PacketSent() method - we are passing the number | ||
324 | // // of bytes sent in a separate parameter, since we can't use buffer.DataLength which | ||
325 | // // is the number of bytes to send (or bytes received depending upon whether this | ||
326 | // // buffer was part of a send or a receive). | ||
327 | // PacketSent(buffer, bytesSent); | ||
328 | // } | ||
329 | // catch (SocketException) | ||
330 | // { | ||
331 | // //Logger.Log( | ||
332 | // // "A SocketException occurred in UDPServer.AsyncEndSend()", | ||
333 | // // Helpers.LogLevel.Error, se); | ||
334 | // } | ||
335 | // } | ||
336 | |||
337 | // Interlocked.Decrement(ref rwOperationCount); | ||
338 | // rwLock.ReleaseReaderLock(); | ||
339 | // } | ||
340 | // } | ||
341 | //} | ||
342 | |||
343 | //--------- Original Version ------------------- | ||
344 | |||
345 | |||
346 | namespace OpenSim.Region.ClientStack.LindenUDP | ||
347 | { | ||
348 | /// <summary> | ||
349 | /// | ||
350 | /// </summary> | ||
351 | public abstract class OpenSimUDPBase | ||
352 | { | ||
353 | // these abstract methods must be implemented in a derived class to actually do | ||
354 | // something with the packets that are sent and received. | ||
355 | protected abstract void PacketReceived(UDPPacketBuffer buffer); | ||
356 | protected abstract void PacketSent(UDPPacketBuffer buffer, int bytesSent); | ||
357 | |||
358 | // the port to listen on | ||
359 | internal int udpPort; | ||
360 | |||
361 | // the UDP socket | ||
362 | private Socket udpSocket; | ||
363 | |||
364 | // the all important shutdownFlag. | ||
365 | private volatile bool shutdownFlag = true; | ||
366 | |||
367 | // the remote endpoint to communicate with | ||
368 | protected IPEndPoint remoteEndPoint = null; | ||
369 | |||
370 | /// <summary> | ||
371 | /// Initialize the UDP packet handler in server mode | ||
372 | /// </summary> | ||
373 | /// <param name="port">Port to listening for incoming UDP packets on</param> | ||
374 | public OpenSimUDPBase(int port) | ||
375 | { | ||
376 | udpPort = port; | ||
377 | } | ||
378 | |||
379 | /// <summary> | ||
380 | /// Initialize the UDP packet handler in client mode | ||
381 | /// </summary> | ||
382 | /// <param name="endPoint">Remote UDP server to connect to</param> | ||
383 | public OpenSimUDPBase(IPEndPoint endPoint) | ||
384 | { | ||
385 | remoteEndPoint = endPoint; | ||
386 | udpPort = 0; | ||
387 | } | ||
388 | |||
389 | /// <summary> | ||
390 | /// | ||
391 | /// </summary> | ||
392 | public void Start() | ||
393 | { | ||
394 | if (shutdownFlag) | ||
395 | { | ||
396 | const int SIO_UDP_CONNRESET = -1744830452; | ||
397 | |||
398 | IPEndPoint ipep = new IPEndPoint(Settings.BIND_ADDR, udpPort); | ||
399 | udpSocket = new Socket( | ||
400 | AddressFamily.InterNetwork, | ||
401 | SocketType.Dgram, | ||
402 | ProtocolType.Udp); | ||
403 | try | ||
404 | { | ||
405 | // this udp socket flag is not supported under mono, | ||
406 | // so we'll catch the exception and continue | ||
407 | udpSocket.IOControl(SIO_UDP_CONNRESET, new byte[] { 0 }, null); | ||
408 | } | ||
409 | catch (SocketException) | ||
410 | { | ||
411 | Logger.DebugLog("UDP SIO_UDP_CONNRESET flag not supported on this platform"); | ||
412 | } | ||
413 | udpSocket.Bind(ipep); | ||
414 | |||
415 | // we're not shutting down, we're starting up | ||
416 | shutdownFlag = false; | ||
417 | |||
418 | // kick off an async receive. The Start() method will return, the | ||
419 | // actual receives will occur asynchronously and will be caught in | ||
420 | // AsyncEndRecieve(). | ||
421 | AsyncBeginReceive(); | ||
422 | } | ||
423 | } | ||
424 | |||
425 | /// <summary> | ||
426 | /// | ||
427 | /// </summary> | ||
428 | public void Stop() | ||
429 | { | ||
430 | if (!shutdownFlag) | ||
431 | { | ||
432 | // wait indefinitely for a writer lock. Once this is called, the .NET runtime | ||
433 | // will deny any more reader locks, in effect blocking all other send/receive | ||
434 | // threads. Once we have the lock, we set shutdownFlag to inform the other | ||
435 | // threads that the socket is closed. | ||
436 | shutdownFlag = true; | ||
437 | udpSocket.Close(); | ||
438 | } | ||
439 | } | ||
440 | |||
441 | /// <summary> | ||
442 | /// | ||
443 | /// </summary> | ||
444 | public bool IsRunning | ||
445 | { | ||
446 | get { return !shutdownFlag; } | ||
447 | } | ||
448 | |||
449 | private void AsyncBeginReceive() | ||
450 | { | ||
451 | // allocate a packet buffer | ||
452 | //WrappedObject<UDPPacketBuffer> wrappedBuffer = Pool.CheckOut(); | ||
453 | UDPPacketBuffer buf = new UDPPacketBuffer(); | ||
454 | |||
455 | if (!shutdownFlag) | ||
456 | { | ||
457 | try | ||
458 | { | ||
459 | // kick off an async read | ||
460 | udpSocket.BeginReceiveFrom( | ||
461 | //wrappedBuffer.Instance.Data, | ||
462 | buf.Data, | ||
463 | 0, | ||
464 | UDPPacketBuffer.BUFFER_SIZE, | ||
465 | SocketFlags.None, | ||
466 | ref buf.RemoteEndPoint, | ||
467 | AsyncEndReceive, | ||
468 | //wrappedBuffer); | ||
469 | buf); | ||
470 | } | ||
471 | catch (SocketException e) | ||
472 | { | ||
473 | if (e.SocketErrorCode == SocketError.ConnectionReset) | ||
474 | { | ||
475 | Logger.Log("SIO_UDP_CONNRESET was ignored, attempting to salvage the UDP listener on port " + udpPort, Helpers.LogLevel.Error); | ||
476 | bool salvaged = false; | ||
477 | while (!salvaged) | ||
478 | { | ||
479 | try | ||
480 | { | ||
481 | udpSocket.BeginReceiveFrom( | ||
482 | //wrappedBuffer.Instance.Data, | ||
483 | buf.Data, | ||
484 | 0, | ||
485 | UDPPacketBuffer.BUFFER_SIZE, | ||
486 | SocketFlags.None, | ||
487 | ref buf.RemoteEndPoint, | ||
488 | AsyncEndReceive, | ||
489 | //wrappedBuffer); | ||
490 | buf); | ||
491 | salvaged = true; | ||
492 | } | ||
493 | catch (SocketException) { } | ||
494 | catch (ObjectDisposedException) { return; } | ||
495 | } | ||
496 | |||
497 | Logger.Log("Salvaged the UDP listener on port " + udpPort, Helpers.LogLevel.Info); | ||
498 | } | ||
499 | } | ||
500 | catch (ObjectDisposedException) { } | ||
501 | } | ||
502 | } | ||
503 | |||
504 | private void AsyncEndReceive(IAsyncResult iar) | ||
505 | { | ||
506 | // Asynchronous receive operations will complete here through the call | ||
507 | // to AsyncBeginReceive | ||
508 | if (!shutdownFlag) | ||
509 | { | ||
510 | // start another receive - this keeps the server going! | ||
511 | AsyncBeginReceive(); | ||
512 | |||
513 | // get the buffer that was created in AsyncBeginReceive | ||
514 | // this is the received data | ||
515 | //WrappedObject<UDPPacketBuffer> wrappedBuffer = (WrappedObject<UDPPacketBuffer>)iar.AsyncState; | ||
516 | //UDPPacketBuffer buffer = wrappedBuffer.Instance; | ||
517 | UDPPacketBuffer buffer = (UDPPacketBuffer)iar.AsyncState; | ||
518 | |||
519 | try | ||
520 | { | ||
521 | // get the length of data actually read from the socket, store it with the | ||
522 | // buffer | ||
523 | buffer.DataLength = udpSocket.EndReceiveFrom(iar, ref buffer.RemoteEndPoint); | ||
524 | |||
525 | // call the abstract method PacketReceived(), passing the buffer that | ||
526 | // has just been filled from the socket read. | ||
527 | PacketReceived(buffer); | ||
528 | } | ||
529 | catch (SocketException) { } | ||
530 | catch (ObjectDisposedException) { } | ||
531 | //finally { wrappedBuffer.Dispose(); } | ||
532 | } | ||
533 | } | ||
534 | |||
535 | public void AsyncBeginSend(UDPPacketBuffer buf) | ||
536 | { | ||
537 | if (!shutdownFlag) | ||
538 | { | ||
539 | try | ||
540 | { | ||
541 | udpSocket.BeginSendTo( | ||
542 | buf.Data, | ||
543 | 0, | ||
544 | buf.DataLength, | ||
545 | SocketFlags.None, | ||
546 | buf.RemoteEndPoint, | ||
547 | AsyncEndSend, | ||
548 | buf); | ||
549 | } | ||
550 | catch (SocketException) { } | ||
551 | catch (ObjectDisposedException) { } | ||
552 | } | ||
553 | } | ||
554 | |||
555 | void AsyncEndSend(IAsyncResult result) | ||
556 | { | ||
557 | try | ||
558 | { | ||
559 | UDPPacketBuffer buf = (UDPPacketBuffer)result.AsyncState; | ||
560 | int bytesSent = udpSocket.EndSendTo(result); | ||
561 | |||
562 | PacketSent(buf, bytesSent); | ||
563 | } | ||
564 | catch (SocketException) { } | ||
565 | catch (ObjectDisposedException) { } | ||
566 | } | ||
567 | } | ||
568 | } | ||
569 | |||
diff --git a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs index 901144a..fe9de1b 100644 --- a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs +++ b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs | |||
@@ -556,6 +556,8 @@ namespace OpenSim.Region.CoreModules.World.Permissions | |||
556 | 556 | ||
557 | // Customize the EveryoneMask | 557 | // Customize the EveryoneMask |
558 | uint objectEveryoneMask = ApplyObjectModifyMasks(task.EveryoneMask, objflags); | 558 | uint objectEveryoneMask = ApplyObjectModifyMasks(task.EveryoneMask, objflags); |
559 | if (objectOwner != UUID.Zero) | ||
560 | objectEveryoneMask |= (uint)PrimFlags.ObjectAnyOwner; | ||
559 | 561 | ||
560 | if (m_bypassPermissions) | 562 | if (m_bypassPermissions) |
561 | return objectOwnerMask; | 563 | return objectOwnerMask; |
@@ -578,12 +580,9 @@ namespace OpenSim.Region.CoreModules.World.Permissions | |||
578 | { | 580 | { |
579 | // Admin objects should not be editable by the above | 581 | // Admin objects should not be editable by the above |
580 | if (!IsAdministrator(objectOwner)) | 582 | if (!IsAdministrator(objectOwner)) |
581 | return objectOwnerMask; | 583 | return objectOwnerMask; |
582 | } | 584 | } |
583 | 585 | ||
584 | if ((objectOwnerMask & (uint)PermissionMask.Transfer) != 0 && task.ObjectSaleType != 0) | ||
585 | objectEveryoneMask |= (uint)PrimFlags.ObjectTransfer; | ||
586 | |||
587 | // Group permissions | 586 | // Group permissions |
588 | if ((task.GroupID != UUID.Zero) && IsGroupMember(task.GroupID, user, 0)) | 587 | if ((task.GroupID != UUID.Zero) && IsGroupMember(task.GroupID, user, 0)) |
589 | return objectGroupMask | objectEveryoneMask; | 588 | return objectGroupMask | objectEveryoneMask; |
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 3996cdc..15fb11f 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs | |||
@@ -3409,7 +3409,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3409 | scene.AddPhysicsActorTaint(m_physicsActor); | 3409 | scene.AddPhysicsActorTaint(m_physicsActor); |
3410 | //m_physicsActor.OnRequestTerseUpdate += SendTerseUpdateToAllClients; | 3410 | //m_physicsActor.OnRequestTerseUpdate += SendTerseUpdateToAllClients; |
3411 | m_physicsActor.OnCollisionUpdate += PhysicsCollisionUpdate; | 3411 | m_physicsActor.OnCollisionUpdate += PhysicsCollisionUpdate; |
3412 | m_physicsActor.SubscribeEvents(1000); | 3412 | m_physicsActor.SubscribeEvents(500); |
3413 | m_physicsActor.LocalID = LocalId; | 3413 | m_physicsActor.LocalID = LocalId; |
3414 | 3414 | ||
3415 | } | 3415 | } |
@@ -3417,7 +3417,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
3417 | // Event called by the physics plugin to tell the avatar about a collision. | 3417 | // Event called by the physics plugin to tell the avatar about a collision. |
3418 | private void PhysicsCollisionUpdate(EventArgs e) | 3418 | private void PhysicsCollisionUpdate(EventArgs e) |
3419 | { | 3419 | { |
3420 | if ((e == null) || m_invulnerable) | 3420 | if (e == null) |
3421 | return; | ||
3422 | |||
3423 | //if ((Math.Abs(Velocity.X) > 0.1e-9f) || (Math.Abs(Velocity.Y) > 0.1e-9f)) | ||
3424 | // The Physics Scene will send updates every 500 ms grep: m_physicsActor.SubscribeEvents( | ||
3425 | // as of this comment the interval is set in AddToPhysicalScene | ||
3426 | UpdateMovementAnimations(); | ||
3427 | |||
3428 | if (m_invulnerable) | ||
3421 | return; | 3429 | return; |
3422 | CollisionEventUpdate collisionData = (CollisionEventUpdate)e; | 3430 | CollisionEventUpdate collisionData = (CollisionEventUpdate)e; |
3423 | Dictionary<uint, float> coldata = collisionData.m_objCollisionList; | 3431 | Dictionary<uint, float> coldata = collisionData.m_objCollisionList; |
@@ -3455,8 +3463,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3455 | m_scene.EventManager.TriggerAvatarKill(killerObj, this); | 3463 | m_scene.EventManager.TriggerAvatarKill(killerObj, this); |
3456 | } | 3464 | } |
3457 | 3465 | ||
3458 | if (Velocity.X > 0 || Velocity.Y > 0) | 3466 | |
3459 | UpdateMovementAnimations(); | ||
3460 | } | 3467 | } |
3461 | 3468 | ||
3462 | public void setHealthWithUpdate(float health) | 3469 | public void setHealthWithUpdate(float health) |
diff --git a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs index a00ba11..bd81d50 100644 --- a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs +++ b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs | |||
@@ -98,6 +98,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
98 | private bool m_alwaysRun = false; | 98 | private bool m_alwaysRun = false; |
99 | private bool m_hackSentFall = false; | 99 | private bool m_hackSentFall = false; |
100 | private bool m_hackSentFly = false; | 100 | private bool m_hackSentFly = false; |
101 | private int m_requestedUpdateFrequency = 0; | ||
101 | private PhysicsVector m_taintPosition = new PhysicsVector(0, 0, 0); | 102 | private PhysicsVector m_taintPosition = new PhysicsVector(0, 0, 0); |
102 | public uint m_localID = 0; | 103 | public uint m_localID = 0; |
103 | public bool m_returnCollisions = false; | 104 | public bool m_returnCollisions = false; |
@@ -1184,26 +1185,31 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1184 | 1185 | ||
1185 | public override void SubscribeEvents(int ms) | 1186 | public override void SubscribeEvents(int ms) |
1186 | { | 1187 | { |
1188 | m_requestedUpdateFrequency = ms; | ||
1187 | m_eventsubscription = ms; | 1189 | m_eventsubscription = ms; |
1188 | _parent_scene.addCollisionEventReporting(this); | 1190 | _parent_scene.addCollisionEventReporting(this); |
1189 | } | 1191 | } |
1190 | public override void UnSubscribeEvents() | 1192 | public override void UnSubscribeEvents() |
1191 | { | 1193 | { |
1192 | _parent_scene.remCollisionEventReporting(this); | 1194 | _parent_scene.remCollisionEventReporting(this); |
1195 | m_requestedUpdateFrequency = 0; | ||
1193 | m_eventsubscription = 0; | 1196 | m_eventsubscription = 0; |
1194 | } | 1197 | } |
1195 | public void AddCollisionEvent(uint CollidedWith, float depth) | 1198 | public void AddCollisionEvent(uint CollidedWith, float depth) |
1196 | { | 1199 | { |
1197 | if (m_eventsubscription > 0) | 1200 | if (m_eventsubscription > 0) |
1198 | CollisionEventsThisFrame.addCollider(CollidedWith,depth); | 1201 | { |
1202 | CollisionEventsThisFrame.addCollider(CollidedWith, depth); | ||
1203 | } | ||
1199 | } | 1204 | } |
1200 | 1205 | ||
1201 | public void SendCollisions() | 1206 | public void SendCollisions() |
1202 | { | 1207 | { |
1203 | if (m_eventsubscription > 0) | 1208 | if (m_eventsubscription > m_requestedUpdateFrequency) |
1204 | { | 1209 | { |
1205 | base.SendCollisionUpdate(CollisionEventsThisFrame); | 1210 | base.SendCollisionUpdate(CollisionEventsThisFrame); |
1206 | CollisionEventsThisFrame = new CollisionEventUpdate(); | 1211 | CollisionEventsThisFrame = new CollisionEventUpdate(); |
1212 | m_eventsubscription = 0; | ||
1207 | } | 1213 | } |
1208 | } | 1214 | } |
1209 | public override bool SubscribedEvents() | 1215 | public override bool SubscribedEvents() |
@@ -1309,5 +1315,13 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1309 | } | 1315 | } |
1310 | 1316 | ||
1311 | } | 1317 | } |
1318 | |||
1319 | internal void AddCollisionFrameTime(int p) | ||
1320 | { | ||
1321 | // protect it from overflow crashing | ||
1322 | if (m_eventsubscription + p >= int.MaxValue) | ||
1323 | m_eventsubscription = 0; | ||
1324 | m_eventsubscription += p; | ||
1325 | } | ||
1312 | } | 1326 | } |
1313 | } | 1327 | } |
diff --git a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs index 57e1349..78831f8 100644 --- a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs +++ b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs | |||
@@ -2940,6 +2940,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
2940 | { | 2940 | { |
2941 | case ActorTypes.Agent: | 2941 | case ActorTypes.Agent: |
2942 | OdeCharacter cobj = (OdeCharacter)obj; | 2942 | OdeCharacter cobj = (OdeCharacter)obj; |
2943 | cobj.AddCollisionFrameTime(100); | ||
2943 | cobj.SendCollisions(); | 2944 | cobj.SendCollisions(); |
2944 | break; | 2945 | break; |
2945 | case ActorTypes.Prim: | 2946 | case ActorTypes.Prim: |
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index e695133..847da8c 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | |||
@@ -642,7 +642,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
642 | m_ScriptErrorMessage += "Failed to compile script in object: '" + part.ParentGroup.RootPart.Name + "' Script name: '" + item.Name + "' Error message: " + e.Message.ToString(); | 642 | m_ScriptErrorMessage += "Failed to compile script in object: '" + part.ParentGroup.RootPart.Name + "' Script name: '" + item.Name + "' Error message: " + e.Message.ToString(); |
643 | 643 | ||
644 | m_ScriptFailCount++; | 644 | m_ScriptFailCount++; |
645 | string text = "Error compiling script:\n" + e.Message.ToString(); | 645 | string text = "Error compiling script '" + item.Name + "':\n" + e.Message.ToString(); |
646 | if (text.Length > 1000) | 646 | if (text.Length > 1000) |
647 | text = text.Substring(0, 1000); | 647 | text = text.Substring(0, 1000); |
648 | World.SimChat(Utils.StringToBytes(text), | 648 | World.SimChat(Utils.StringToBytes(text), |