aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs
diff options
context:
space:
mode:
authorMelanie2012-10-12 19:05:06 +0100
committerMelanie2012-10-12 19:05:06 +0100
commit6ce93b22d1bc0f2a89c0d7a8d79bfe8c85a2d9b4 (patch)
treed81136f8cc2c602d5cc6b783e5cb3d23343a089e /OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs
parentMerge branch 'avination' into careminster (diff)
parentBulletSim: only use native sphere shape if it is a sphere. (diff)
downloadopensim-SC_OLD-6ce93b22d1bc0f2a89c0d7a8d79bfe8c85a2d9b4.zip
opensim-SC_OLD-6ce93b22d1bc0f2a89c0d7a8d79bfe8c85a2d9b4.tar.gz
opensim-SC_OLD-6ce93b22d1bc0f2a89c0d7a8d79bfe8c85a2d9b4.tar.bz2
opensim-SC_OLD-6ce93b22d1bc0f2a89c0d7a8d79bfe8c85a2d9b4.tar.xz
Merge branch 'master' into careminster
Conflicts: OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs OpenSim/Region/Framework/Scenes/Scene.cs
Diffstat (limited to 'OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs')
-rw-r--r--OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs36
1 files changed, 27 insertions, 9 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs
index b3db064..97b79ce 100644
--- a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs
+++ b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs
@@ -100,9 +100,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP
100 100
101 /// <summary>The measured resolution of Environment.TickCount</summary> 101 /// <summary>The measured resolution of Environment.TickCount</summary>
102 public readonly float TickCountResolution; 102 public readonly float TickCountResolution;
103
103 /// <summary>Number of prim updates to put on the queue each time the 104 /// <summary>Number of prim updates to put on the queue each time the
104 /// OnQueueEmpty event is triggered for updates</summary> 105 /// OnQueueEmpty event is triggered for updates</summary>
105 public readonly int PrimUpdatesPerCallback; 106 public readonly int PrimUpdatesPerCallback;
107
106 /// <summary>Number of texture packets to put on the queue each time the 108 /// <summary>Number of texture packets to put on the queue each time the
107 /// OnQueueEmpty event is triggered for textures</summary> 109 /// OnQueueEmpty event is triggered for textures</summary>
108 public readonly int TextureSendLimit; 110 public readonly int TextureSendLimit;
@@ -124,28 +126,37 @@ namespace OpenSim.Region.ClientStack.LindenUDP
124 126
125 /// <summary>Manages authentication for agent circuits</summary> 127 /// <summary>Manages authentication for agent circuits</summary>
126 private AgentCircuitManager m_circuitManager; 128 private AgentCircuitManager m_circuitManager;
129
127 /// <summary>Reference to the scene this UDP server is attached to</summary> 130 /// <summary>Reference to the scene this UDP server is attached to</summary>
128 protected Scene m_scene; 131 protected Scene m_scene;
132
129 /// <summary>The X/Y coordinates of the scene this UDP server is attached to</summary> 133 /// <summary>The X/Y coordinates of the scene this UDP server is attached to</summary>
130 private Location m_location; 134 private Location m_location;
135
131 /// <summary>The size of the receive buffer for the UDP socket. This value 136 /// <summary>The size of the receive buffer for the UDP socket. This value
132 /// is passed up to the operating system and used in the system networking 137 /// is passed up to the operating system and used in the system networking
133 /// stack. Use zero to leave this value as the default</summary> 138 /// stack. Use zero to leave this value as the default</summary>
134 private int m_recvBufferSize; 139 private int m_recvBufferSize;
140
135 /// <summary>Flag to process packets asynchronously or synchronously</summary> 141 /// <summary>Flag to process packets asynchronously or synchronously</summary>
136 private bool m_asyncPacketHandling; 142 private bool m_asyncPacketHandling;
143
137 /// <summary>Tracks whether or not a packet was sent each round so we know 144 /// <summary>Tracks whether or not a packet was sent each round so we know
138 /// whether or not to sleep</summary> 145 /// whether or not to sleep</summary>
139 private bool m_packetSent; 146 private bool m_packetSent;
140 147
141 /// <summary>Environment.TickCount of the last time that packet stats were reported to the scene</summary> 148 /// <summary>Environment.TickCount of the last time that packet stats were reported to the scene</summary>
142 private int m_elapsedMSSinceLastStatReport = 0; 149 private int m_elapsedMSSinceLastStatReport = 0;
150
143 /// <summary>Environment.TickCount of the last time the outgoing packet handler executed</summary> 151 /// <summary>Environment.TickCount of the last time the outgoing packet handler executed</summary>
144 private int m_tickLastOutgoingPacketHandler; 152 private int m_tickLastOutgoingPacketHandler;
153
145 /// <summary>Keeps track of the number of elapsed milliseconds since the last time the outgoing packet handler looped</summary> 154 /// <summary>Keeps track of the number of elapsed milliseconds since the last time the outgoing packet handler looped</summary>
146 private int m_elapsedMSOutgoingPacketHandler; 155 private int m_elapsedMSOutgoingPacketHandler;
156
147 /// <summary>Keeps track of the number of 100 millisecond periods elapsed in the outgoing packet handler executed</summary> 157 /// <summary>Keeps track of the number of 100 millisecond periods elapsed in the outgoing packet handler executed</summary>
148 private int m_elapsed100MSOutgoingPacketHandler; 158 private int m_elapsed100MSOutgoingPacketHandler;
159
149 /// <summary>Keeps track of the number of 500 millisecond periods elapsed in the outgoing packet handler executed</summary> 160 /// <summary>Keeps track of the number of 500 millisecond periods elapsed in the outgoing packet handler executed</summary>
150 private int m_elapsed500MSOutgoingPacketHandler; 161 private int m_elapsed500MSOutgoingPacketHandler;
151 162
@@ -425,6 +436,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
425 byte[] data = packet.ToBytes(); 436 byte[] data = packet.ToBytes();
426 SendPacketData(udpClient, data, packet.Type, category, method); 437 SendPacketData(udpClient, data, packet.Type, category, method);
427 } 438 }
439
440 PacketPool.Instance.ReturnPacket(packet);
428 } 441 }
429 442
430 /// <summary> 443 /// <summary>
@@ -742,7 +755,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP
742 755
743 try 756 try
744 { 757 {
745 packet = Packet.BuildPacket(buffer.Data, ref packetEnd, 758// packet = Packet.BuildPacket(buffer.Data, ref packetEnd,
759// // Only allocate a buffer for zerodecoding if the packet is zerocoded
760// ((buffer.Data[0] & Helpers.MSG_ZEROCODED) != 0) ? new byte[4096] : null);
761 packet = PacketPool.Instance.GetPacket(buffer.Data, ref packetEnd,
746 // Only allocate a buffer for zerodecoding if the packet is zerocoded 762 // Only allocate a buffer for zerodecoding if the packet is zerocoded
747 ((buffer.Data[0] & Helpers.MSG_ZEROCODED) != 0) ? new byte[4096] : null); 763 ((buffer.Data[0] & Helpers.MSG_ZEROCODED) != 0) ? new byte[4096] : null);
748 } 764 }
@@ -757,11 +773,13 @@ namespace OpenSim.Region.ClientStack.LindenUDP
757 773
758 return; // Drop short packet 774 return; // Drop short packet
759 } 775 }
760 catch(Exception e) 776 catch (Exception e)
761 { 777 {
762 if (m_malformedCount < 100) 778 if (m_malformedCount < 100)
763 m_log.DebugFormat("[LLUDPSERVER]: Dropped malformed packet: " + e.ToString()); 779 m_log.DebugFormat("[LLUDPSERVER]: Dropped malformed packet: " + e.ToString());
780
764 m_malformedCount++; 781 m_malformedCount++;
782
765 if ((m_malformedCount % 100000) == 0) 783 if ((m_malformedCount % 100000) == 0)
766 m_log.DebugFormat("[LLUDPSERVER]: Received {0} malformed packets so far, probable network attack.", m_malformedCount); 784 m_log.DebugFormat("[LLUDPSERVER]: Received {0} malformed packets so far, probable network attack.", m_malformedCount);
767 } 785 }
@@ -1169,20 +1187,20 @@ namespace OpenSim.Region.ClientStack.LindenUDP
1169 { 1187 {
1170 IClientAPI client = null; 1188 IClientAPI client = null;
1171 1189
1172 // In priciple there shouldn't be more than one thread here, ever. 1190 // We currently synchronize this code across the whole scene to avoid issues such as
1173 // But in case that happens, we need to synchronize this piece of code 1191 // http://opensimulator.org/mantis/view.php?id=5365 However, once locking per agent circuit can be done
1174 // because it's too important 1192 // consistently, this lock could probably be removed.
1175 lock (this) 1193 lock (this)
1176 { 1194 {
1177 if (!m_scene.TryGetClient(agentID, out client)) 1195 if (!m_scene.TryGetClient(agentID, out client))
1178 { 1196 {
1179 LLUDPClient udpClient = new LLUDPClient(this, ThrottleRates, m_throttle, circuitCode, agentID, remoteEndPoint, m_defaultRTO, m_maxRTO); 1197 LLUDPClient udpClient = new LLUDPClient(this, ThrottleRates, m_throttle, circuitCode, agentID, remoteEndPoint, m_defaultRTO, m_maxRTO);
1180 1198
1181 client = new LLClientView(m_scene, this, udpClient, sessionInfo, agentID, sessionID, circuitCode); 1199 client = new LLClientView(m_scene, this, udpClient, sessionInfo, agentID, sessionID, circuitCode);
1182 client.OnLogout += LogoutHandler; 1200 client.OnLogout += LogoutHandler;
1183 1201
1184 ((LLClientView)client).DisableFacelights = m_disableFacelights; 1202 ((LLClientView)client).DisableFacelights = m_disableFacelights;
1185 1203
1186 client.Start(); 1204 client.Start();
1187 } 1205 }
1188 } 1206 }