aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs27
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/OpenSimUDPBase.cs107
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/OutgoingPacket.cs4
3 files changed, 6 insertions, 132 deletions
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs
index 4d9f58f..3c4fa72 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs
@@ -402,7 +402,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
402 #region Queue or Send 402 #region Queue or Send
403 403
404 OutgoingPacket outgoingPacket = new OutgoingPacket(udpClient, buffer, category); 404 OutgoingPacket outgoingPacket = new OutgoingPacket(udpClient, buffer, category);
405 outgoingPacket.Type = type;
406 405
407 if (!outgoingPacket.Client.EnqueueOutgoing(outgoingPacket)) 406 if (!outgoingPacket.Client.EnqueueOutgoing(outgoingPacket))
408 SendPacketFinal(outgoingPacket); 407 SendPacketFinal(outgoingPacket);
@@ -514,7 +513,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
514 byte flags = buffer.Data[0]; 513 byte flags = buffer.Data[0];
515 bool isResend = (flags & Helpers.MSG_RESENT) != 0; 514 bool isResend = (flags & Helpers.MSG_RESENT) != 0;
516 bool isReliable = (flags & Helpers.MSG_RELIABLE) != 0; 515 bool isReliable = (flags & Helpers.MSG_RELIABLE) != 0;
517 bool sendSynchronous = false;
518 LLUDPClient udpClient = outgoingPacket.Client; 516 LLUDPClient udpClient = outgoingPacket.Client;
519 517
520 if (!udpClient.IsConnected) 518 if (!udpClient.IsConnected)
@@ -570,28 +568,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
570 if (isReliable) 568 if (isReliable)
571 Interlocked.Add(ref udpClient.UnackedBytes, outgoingPacket.Buffer.DataLength); 569 Interlocked.Add(ref udpClient.UnackedBytes, outgoingPacket.Buffer.DataLength);
572 570
573 //Some packet types need to be sent synchonously.
574 //Sorry, i know it's not optimal, but until the LL client
575 //manages packets correctly and re-orders them as required, this is necessary.
576
577
578 // Put the UDP payload on the wire 571 // Put the UDP payload on the wire
579 if (outgoingPacket.Type == PacketType.ImprovedTerseObjectUpdate) 572 AsyncBeginSend(buffer);
580 { 573
581 SyncBeginPrioritySend(buffer, 2); // highest priority
582 }
583 else if (outgoingPacket.Type == PacketType.ObjectUpdate
584 || outgoingPacket.Type == PacketType.LayerData)
585 {
586 SyncBeginPrioritySend(buffer, 1); // medium priority
587 }
588 else
589 {
590 SyncBeginPrioritySend(buffer, 0); // normal priority
591 }
592
593 //AsyncBeginSend(buffer);
594
595 // Keep track of when this packet was sent out (right now) 574 // Keep track of when this packet was sent out (right now)
596 outgoingPacket.TickCount = Environment.TickCount & Int32.MaxValue; 575 outgoingPacket.TickCount = Environment.TickCount & Int32.MaxValue;
597 } 576 }
@@ -872,7 +851,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
872 851
873 Buffer.BlockCopy(packetData, 0, buffer.Data, 0, length); 852 Buffer.BlockCopy(packetData, 0, buffer.Data, 0, length);
874 853
875 SyncBeginPrioritySend(buffer, 1); //Setting this to a medium priority should help minimise resends 854 AsyncBeginSend(buffer);
876 } 855 }
877 856
878 private bool IsClientAuthorized(UseCircuitCodePacket useCircuitCode, out AuthenticateResponse sessionInfo) 857 private bool IsClientAuthorized(UseCircuitCodePacket useCircuitCode, out AuthenticateResponse sessionInfo)
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;
29using System.Net; 29using System.Net;
30using System.Net.Sockets; 30using System.Net.Sockets;
31using System.Threading; 31using System.Threading;
32using System.Collections.Generic;
33using log4net; 32using log4net;
34 33
35namespace OpenMetaverse 34namespace 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) { }
diff --git a/OpenSim/Region/ClientStack/LindenUDP/OutgoingPacket.cs b/OpenSim/Region/ClientStack/LindenUDP/OutgoingPacket.cs
index 7dc42d3..1a1a1cb 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/OutgoingPacket.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/OutgoingPacket.cs
@@ -28,7 +28,6 @@
28using System; 28using System;
29using OpenSim.Framework; 29using OpenSim.Framework;
30using OpenMetaverse; 30using OpenMetaverse;
31using OpenMetaverse.Packets;
32 31
33namespace OpenSim.Region.ClientStack.LindenUDP 32namespace OpenSim.Region.ClientStack.LindenUDP
34{ 33{
@@ -53,8 +52,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
53 public int TickCount; 52 public int TickCount;
54 /// <summary>Category this packet belongs to</summary> 53 /// <summary>Category this packet belongs to</summary>
55 public ThrottleOutPacketType Category; 54 public ThrottleOutPacketType Category;
56 /// <summary>The type of packet so its delivery method can be determined</summary> 55
57 public PacketType Type;
58 /// <summary> 56 /// <summary>
59 /// Default constructor 57 /// Default constructor
60 /// </summary> 58 /// </summary>