diff options
author | CasperW | 2009-12-20 16:20:48 +0100 |
---|---|---|
committer | CasperW | 2009-12-20 16:20:48 +0100 |
commit | c7a457f9eee62dc793ea68de5ffa74f6a990990f (patch) | |
tree | 134099d9e169df630cf25b48a615ff67014d31f1 /OpenSim/Region/ClientStack/LindenUDP/OpenSimUDPBase.cs | |
parent | Merge branch 'tests' (diff) | |
parent | Reverted my changes to jhurliman's packet stack since it currently causes mor... (diff) | |
download | opensim-SC-c7a457f9eee62dc793ea68de5ffa74f6a990990f.zip opensim-SC-c7a457f9eee62dc793ea68de5ffa74f6a990990f.tar.gz opensim-SC-c7a457f9eee62dc793ea68de5ffa74f6a990990f.tar.bz2 opensim-SC-c7a457f9eee62dc793ea68de5ffa74f6a990990f.tar.xz |
Merge branch 'casper'
Diffstat (limited to 'OpenSim/Region/ClientStack/LindenUDP/OpenSimUDPBase.cs')
-rw-r--r-- | OpenSim/Region/ClientStack/LindenUDP/OpenSimUDPBase.cs | 107 |
1 files changed, 2 insertions, 105 deletions
diff --git a/OpenSim/Region/ClientStack/LindenUDP/OpenSimUDPBase.cs b/OpenSim/Region/ClientStack/LindenUDP/OpenSimUDPBase.cs index de2cd24..d2779ba 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/OpenSimUDPBase.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/OpenSimUDPBase.cs | |||
@@ -29,7 +29,6 @@ using System; | |||
29 | using System.Net; | 29 | using System.Net; |
30 | using System.Net.Sockets; | 30 | using System.Net.Sockets; |
31 | using System.Threading; | 31 | using System.Threading; |
32 | using System.Collections.Generic; | ||
33 | using log4net; | 32 | using log4net; |
34 | 33 | ||
35 | namespace OpenMetaverse | 34 | namespace OpenMetaverse |
@@ -53,30 +52,12 @@ namespace OpenMetaverse | |||
53 | /// <summary>Local IP address to bind to in server mode</summary> | 52 | /// <summary>Local IP address to bind to in server mode</summary> |
54 | protected IPAddress m_localBindAddress; | 53 | protected IPAddress m_localBindAddress; |
55 | 54 | ||
56 | /// <summary> | ||
57 | /// Standard queue for our outgoing SyncBeginPrioritySend | ||
58 | /// </summary> | ||
59 | private List<UDPPacketBuffer> m_standardQueue = new List<UDPPacketBuffer>(); | ||
60 | |||
61 | /// <summary> | ||
62 | /// Medium priority queue for our outgoing SyncBeginPrioritySend | ||
63 | /// </summary> | ||
64 | private List<UDPPacketBuffer> m_mediumPriorityQueue = new List<UDPPacketBuffer>(); | ||
65 | |||
66 | /// <summary> | ||
67 | /// Prioritised queue for our outgoing SyncBeginPrioritySend | ||
68 | /// </summary> | ||
69 | private List<UDPPacketBuffer> m_priorityQueue = new List<UDPPacketBuffer>(); | ||
70 | |||
71 | /// <summary>UDP socket, used in either client or server mode</summary> | 55 | /// <summary>UDP socket, used in either client or server mode</summary> |
72 | private Socket m_udpSocket; | 56 | private Socket m_udpSocket; |
73 | 57 | ||
74 | /// <summary>Flag to process packets asynchronously or synchronously</summary> | 58 | /// <summary>Flag to process packets asynchronously or synchronously</summary> |
75 | private bool m_asyncPacketHandling; | 59 | private bool m_asyncPacketHandling; |
76 | 60 | ||
77 | /// <summary>Are we currently sending data asynchronously?</summary> | ||
78 | private volatile bool m_sendingData = false; | ||
79 | |||
80 | /// <summary>The all important shutdown flag</summary> | 61 | /// <summary>The all important shutdown flag</summary> |
81 | private volatile bool m_shutdownFlag = true; | 62 | private volatile bool m_shutdownFlag = true; |
82 | 63 | ||
@@ -265,51 +246,7 @@ namespace OpenMetaverse | |||
265 | } | 246 | } |
266 | } | 247 | } |
267 | 248 | ||
268 | public void SyncBeginPrioritySend(UDPPacketBuffer buf, int Priority) | 249 | public void AsyncBeginSend(UDPPacketBuffer buf) |
269 | { | ||
270 | if (!m_shutdownFlag) | ||
271 | { | ||
272 | if (!m_sendingData) | ||
273 | { | ||
274 | m_sendingData = true; | ||
275 | try | ||
276 | { | ||
277 | AsyncBeginSend(buf); | ||
278 | } | ||
279 | catch (SocketException) { } | ||
280 | catch (ObjectDisposedException) { } | ||
281 | } | ||
282 | else | ||
283 | { | ||
284 | if (Priority == 2) | ||
285 | { | ||
286 | lock (m_priorityQueue) | ||
287 | { | ||
288 | m_priorityQueue.Add(buf); | ||
289 | } | ||
290 | } | ||
291 | else | ||
292 | { | ||
293 | if (Priority != 0) | ||
294 | { | ||
295 | lock (m_mediumPriorityQueue) | ||
296 | { | ||
297 | m_mediumPriorityQueue.Add(buf); | ||
298 | } | ||
299 | } | ||
300 | else | ||
301 | { | ||
302 | lock (m_standardQueue) | ||
303 | { | ||
304 | m_standardQueue.Add(buf); | ||
305 | } | ||
306 | } | ||
307 | } | ||
308 | } | ||
309 | } | ||
310 | } | ||
311 | |||
312 | private void AsyncBeginSend(UDPPacketBuffer buf) | ||
313 | { | 250 | { |
314 | if (!m_shutdownFlag) | 251 | if (!m_shutdownFlag) |
315 | { | 252 | { |
@@ -333,48 +270,8 @@ namespace OpenMetaverse | |||
333 | { | 270 | { |
334 | try | 271 | try |
335 | { | 272 | { |
273 | // UDPPacketBuffer buf = (UDPPacketBuffer)result.AsyncState; | ||
336 | m_udpSocket.EndSendTo(result); | 274 | m_udpSocket.EndSendTo(result); |
337 | |||
338 | if (m_sendingData) | ||
339 | { | ||
340 | lock (m_priorityQueue) | ||
341 | { | ||
342 | if (m_priorityQueue.Count > 0) | ||
343 | { | ||
344 | UDPPacketBuffer buf = m_priorityQueue[0]; | ||
345 | m_priorityQueue.RemoveAt(0); | ||
346 | AsyncBeginSend(buf); | ||
347 | } | ||
348 | else | ||
349 | { | ||
350 | lock (m_mediumPriorityQueue) | ||
351 | { | ||
352 | if (m_mediumPriorityQueue.Count > 0) | ||
353 | { | ||
354 | UDPPacketBuffer buf = m_mediumPriorityQueue[0]; | ||
355 | m_mediumPriorityQueue.RemoveAt(0); | ||
356 | AsyncBeginSend(buf); | ||
357 | } | ||
358 | else | ||
359 | { | ||
360 | lock (m_standardQueue) | ||
361 | { | ||
362 | if (m_standardQueue.Count > 0) | ||
363 | { | ||
364 | UDPPacketBuffer buf = m_standardQueue[0]; | ||
365 | m_standardQueue.RemoveAt(0); | ||
366 | AsyncBeginSend(buf); | ||
367 | } | ||
368 | else | ||
369 | { | ||
370 | m_sendingData = false; | ||
371 | } | ||
372 | } | ||
373 | } | ||
374 | } | ||
375 | } | ||
376 | } | ||
377 | } | ||
378 | } | 275 | } |
379 | catch (SocketException) { } | 276 | catch (SocketException) { } |
380 | catch (ObjectDisposedException) { } | 277 | catch (ObjectDisposedException) { } |