diff options
author | UbitUmarov | 2012-07-17 00:54:23 +0100 |
---|---|---|
committer | UbitUmarov | 2012-07-17 00:54:23 +0100 |
commit | d5f4fb7b50fb7c594b018f8241399e22f88fc951 (patch) | |
tree | 8f3dab3d170596f02b1d1d836a0bc08a3e6b8ebd /OpenSim/Region/ClientStack/Linden/UDP | |
parent | UbitOde: remove useless water collider from active code. (diff) | |
parent | Merge branch 'avination' into careminster (diff) | |
download | opensim-SC-d5f4fb7b50fb7c594b018f8241399e22f88fc951.zip opensim-SC-d5f4fb7b50fb7c594b018f8241399e22f88fc951.tar.gz opensim-SC-d5f4fb7b50fb7c594b018f8241399e22f88fc951.tar.bz2 opensim-SC-d5f4fb7b50fb7c594b018f8241399e22f88fc951.tar.xz |
Merge branch 'avination' into ubitwork
Diffstat (limited to '')
7 files changed, 267 insertions, 182 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/IncomingPacket.cs b/OpenSim/Region/ClientStack/Linden/UDP/IncomingPacket.cs index 90b3ede..1b8535c 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/IncomingPacket.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/IncomingPacket.cs | |||
@@ -39,7 +39,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
39 | public sealed class IncomingPacket | 39 | public sealed class IncomingPacket |
40 | { | 40 | { |
41 | /// <summary>Client this packet came from</summary> | 41 | /// <summary>Client this packet came from</summary> |
42 | public LLUDPClient Client; | 42 | public LLClientView Client; |
43 | |||
43 | /// <summary>Packet data that has been received</summary> | 44 | /// <summary>Packet data that has been received</summary> |
44 | public Packet Packet; | 45 | public Packet Packet; |
45 | 46 | ||
@@ -48,7 +49,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
48 | /// </summary> | 49 | /// </summary> |
49 | /// <param name="client">Reference to the client this packet came from</param> | 50 | /// <param name="client">Reference to the client this packet came from</param> |
50 | /// <param name="packet">Packet data</param> | 51 | /// <param name="packet">Packet data</param> |
51 | public IncomingPacket(LLUDPClient client, Packet packet) | 52 | public IncomingPacket(LLClientView client, Packet packet) |
52 | { | 53 | { |
53 | Client = client; | 54 | Client = client; |
54 | Packet = packet; | 55 | Packet = packet; |
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs index 9c96b52..e6289bd 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs | |||
@@ -59,7 +59,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
59 | /// Handles new client connections | 59 | /// Handles new client connections |
60 | /// Constructor takes a single Packet and authenticates everything | 60 | /// Constructor takes a single Packet and authenticates everything |
61 | /// </summary> | 61 | /// </summary> |
62 | public class LLClientView : IClientAPI, IClientCore, IClientIM, IClientChat, IClientInventory, IClientIPEndpoint, IStatsCollector | 62 | public class LLClientView : IClientAPI, IClientCore, IClientIM, IClientChat, IClientInventory, IStatsCollector |
63 | { | 63 | { |
64 | /// <value> | 64 | /// <value> |
65 | /// Debug packet level. See OpenSim.RegisterConsoleCommands() for more details. | 65 | /// Debug packet level. See OpenSim.RegisterConsoleCommands() for more details. |
@@ -365,7 +365,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
365 | protected string m_lastName; | 365 | protected string m_lastName; |
366 | protected Thread m_clientThread; | 366 | protected Thread m_clientThread; |
367 | protected Vector3 m_startpos; | 367 | protected Vector3 m_startpos; |
368 | protected EndPoint m_userEndPoint; | ||
369 | protected UUID m_activeGroupID; | 368 | protected UUID m_activeGroupID; |
370 | protected string m_activeGroupName = String.Empty; | 369 | protected string m_activeGroupName = String.Empty; |
371 | protected ulong m_activeGroupPowers; | 370 | protected ulong m_activeGroupPowers; |
@@ -458,7 +457,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
458 | /// <summary> | 457 | /// <summary> |
459 | /// Constructor | 458 | /// Constructor |
460 | /// </summary> | 459 | /// </summary> |
461 | public LLClientView(EndPoint remoteEP, Scene scene, LLUDPServer udpServer, LLUDPClient udpClient, AuthenticateResponse sessionInfo, | 460 | public LLClientView(Scene scene, LLUDPServer udpServer, LLUDPClient udpClient, AuthenticateResponse sessionInfo, |
462 | UUID agentId, UUID sessionId, uint circuitCode) | 461 | UUID agentId, UUID sessionId, uint circuitCode) |
463 | { | 462 | { |
464 | // DebugPacketLevel = 1; | 463 | // DebugPacketLevel = 1; |
@@ -466,7 +465,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
466 | RegisterInterface<IClientIM>(this); | 465 | RegisterInterface<IClientIM>(this); |
467 | RegisterInterface<IClientInventory>(this); | 466 | RegisterInterface<IClientInventory>(this); |
468 | RegisterInterface<IClientChat>(this); | 467 | RegisterInterface<IClientChat>(this); |
469 | RegisterInterface<IClientIPEndpoint>(this); | ||
470 | 468 | ||
471 | m_scene = scene; | 469 | m_scene = scene; |
472 | m_entityUpdates = new PriorityQueue(m_scene.Entities.Count); | 470 | m_entityUpdates = new PriorityQueue(m_scene.Entities.Count); |
@@ -483,7 +481,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
483 | m_sessionId = sessionId; | 481 | m_sessionId = sessionId; |
484 | m_secureSessionId = sessionInfo.LoginInfo.SecureSession; | 482 | m_secureSessionId = sessionInfo.LoginInfo.SecureSession; |
485 | m_circuitCode = circuitCode; | 483 | m_circuitCode = circuitCode; |
486 | m_userEndPoint = remoteEP; | ||
487 | m_firstName = sessionInfo.LoginInfo.First; | 484 | m_firstName = sessionInfo.LoginInfo.First; |
488 | m_lastName = sessionInfo.LoginInfo.Last; | 485 | m_lastName = sessionInfo.LoginInfo.Last; |
489 | m_startpos = sessionInfo.LoginInfo.StartPos; | 486 | m_startpos = sessionInfo.LoginInfo.StartPos; |
@@ -515,6 +512,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
515 | /// </summary> | 512 | /// </summary> |
516 | public void Close(bool sendStop) | 513 | public void Close(bool sendStop) |
517 | { | 514 | { |
515 | IsActive = false; | ||
516 | |||
518 | m_log.DebugFormat( | 517 | m_log.DebugFormat( |
519 | "[CLIENT]: Close has been called for {0} attached to scene {1}", | 518 | "[CLIENT]: Close has been called for {0} attached to scene {1}", |
520 | Name, m_scene.RegionInfo.RegionName); | 519 | Name, m_scene.RegionInfo.RegionName); |
@@ -3902,7 +3901,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
3902 | canUseImproved = false; | 3901 | canUseImproved = false; |
3903 | } | 3902 | } |
3904 | } | 3903 | } |
3905 | 3904 | ||
3906 | #endregion UpdateFlags to packet type conversion | 3905 | #endregion UpdateFlags to packet type conversion |
3907 | 3906 | ||
3908 | #region Block Construction | 3907 | #region Block Construction |
@@ -11866,7 +11865,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
11866 | if (DebugPacketLevel <= 100 && (packet.Type == PacketType.AvatarAnimation || packet.Type == PacketType.ViewerEffect)) | 11865 | if (DebugPacketLevel <= 100 && (packet.Type == PacketType.AvatarAnimation || packet.Type == PacketType.ViewerEffect)) |
11867 | logPacket = false; | 11866 | logPacket = false; |
11868 | 11867 | ||
11869 | if (DebugPacketLevel <= 50 && packet.Type == PacketType.ImprovedTerseObjectUpdate) | 11868 | if (DebugPacketLevel <= 50 |
11869 | & (packet.Type == PacketType.ImprovedTerseObjectUpdate || packet.Type == PacketType.ObjectUpdate)) | ||
11870 | logPacket = false; | 11870 | logPacket = false; |
11871 | 11871 | ||
11872 | if (DebugPacketLevel <= 25 && packet.Type == PacketType.ObjectPropertiesFamily) | 11872 | if (DebugPacketLevel <= 25 && packet.Type == PacketType.ObjectPropertiesFamily) |
@@ -11979,7 +11979,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
11979 | { | 11979 | { |
11980 | ClientInfo info = m_udpClient.GetClientInfo(); | 11980 | ClientInfo info = m_udpClient.GetClientInfo(); |
11981 | 11981 | ||
11982 | info.userEP = m_userEndPoint; | ||
11983 | info.proxyEP = null; | 11982 | info.proxyEP = null; |
11984 | info.agentcircuit = RequestClientInfo(); | 11983 | info.agentcircuit = RequestClientInfo(); |
11985 | 11984 | ||
@@ -11991,11 +11990,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
11991 | m_udpClient.SetClientInfo(info); | 11990 | m_udpClient.SetClientInfo(info); |
11992 | } | 11991 | } |
11993 | 11992 | ||
11994 | public EndPoint GetClientEP() | ||
11995 | { | ||
11996 | return m_userEndPoint; | ||
11997 | } | ||
11998 | |||
11999 | #region Media Parcel Members | 11993 | #region Media Parcel Members |
12000 | 11994 | ||
12001 | public void SendParcelMediaCommand(uint flags, ParcelMediaCommandEnum command, float time) | 11995 | public void SendParcelMediaCommand(uint flags, ParcelMediaCommandEnum command, float time) |
@@ -12076,10 +12070,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
12076 | return string.Empty; | 12070 | return string.Empty; |
12077 | } | 12071 | } |
12078 | 12072 | ||
12079 | public void KillEndDone() | ||
12080 | { | ||
12081 | } | ||
12082 | |||
12083 | #region IClientCore | 12073 | #region IClientCore |
12084 | 12074 | ||
12085 | private readonly Dictionary<Type, object> m_clientInterfaces = new Dictionary<Type, object>(); | 12075 | private readonly Dictionary<Type, object> m_clientInterfaces = new Dictionary<Type, object>(); |
@@ -12167,21 +12157,24 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
12167 | protected void MakeAssetRequest(TransferRequestPacket transferRequest, UUID taskID) | 12157 | protected void MakeAssetRequest(TransferRequestPacket transferRequest, UUID taskID) |
12168 | { | 12158 | { |
12169 | UUID requestID = UUID.Zero; | 12159 | UUID requestID = UUID.Zero; |
12170 | if (transferRequest.TransferInfo.SourceType == (int)SourceType.Asset) | 12160 | int sourceType = transferRequest.TransferInfo.SourceType; |
12161 | |||
12162 | if (sourceType == (int)SourceType.Asset) | ||
12171 | { | 12163 | { |
12172 | requestID = new UUID(transferRequest.TransferInfo.Params, 0); | 12164 | requestID = new UUID(transferRequest.TransferInfo.Params, 0); |
12173 | } | 12165 | } |
12174 | else if (transferRequest.TransferInfo.SourceType == (int)SourceType.SimInventoryItem) | 12166 | else if (sourceType == (int)SourceType.SimInventoryItem) |
12175 | { | 12167 | { |
12176 | requestID = new UUID(transferRequest.TransferInfo.Params, 80); | 12168 | requestID = new UUID(transferRequest.TransferInfo.Params, 80); |
12177 | } | 12169 | } |
12178 | else if (transferRequest.TransferInfo.SourceType == (int)SourceType.SimEstate) | 12170 | else if (sourceType == (int)SourceType.SimEstate) |
12179 | { | 12171 | { |
12180 | requestID = taskID; | 12172 | requestID = taskID; |
12181 | } | 12173 | } |
12182 | 12174 | ||
12183 | 12175 | // m_log.DebugFormat( | |
12184 | // m_log.DebugFormat("[CLIENT]: {0} requesting asset {1}", Name, requestID); | 12176 | // "[LLCLIENTVIEW]: Received transfer request for {0} in {1} type {2} by {3}", |
12177 | // requestID, taskID, (SourceType)sourceType, Name); | ||
12185 | 12178 | ||
12186 | 12179 | ||
12187 | //Note, the bool returned from the below function is useless since it is always false. | 12180 | //Note, the bool returned from the below function is useless since it is always false. |
@@ -12270,24 +12263,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
12270 | return numPackets; | 12263 | return numPackets; |
12271 | } | 12264 | } |
12272 | 12265 | ||
12273 | #region IClientIPEndpoint Members | ||
12274 | |||
12275 | public IPAddress EndPoint | ||
12276 | { | ||
12277 | get | ||
12278 | { | ||
12279 | if (m_userEndPoint is IPEndPoint) | ||
12280 | { | ||
12281 | IPEndPoint ep = (IPEndPoint)m_userEndPoint; | ||
12282 | |||
12283 | return ep.Address; | ||
12284 | } | ||
12285 | return null; | ||
12286 | } | ||
12287 | } | ||
12288 | |||
12289 | #endregion | ||
12290 | |||
12291 | public void SendRebakeAvatarTextures(UUID textureID) | 12266 | public void SendRebakeAvatarTextures(UUID textureID) |
12292 | { | 12267 | { |
12293 | RebakeAvatarTexturesPacket pack = | 12268 | RebakeAvatarTexturesPacket pack = |
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs index 46337b3..79e35f4 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs | |||
@@ -147,23 +147,36 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
147 | private int m_elapsed500MSOutgoingPacketHandler; | 147 | private int m_elapsed500MSOutgoingPacketHandler; |
148 | 148 | ||
149 | /// <summary>Flag to signal when clients should check for resends</summary> | 149 | /// <summary>Flag to signal when clients should check for resends</summary> |
150 | private bool m_resendUnacked; | 150 | protected bool m_resendUnacked; |
151 | |||
151 | /// <summary>Flag to signal when clients should send ACKs</summary> | 152 | /// <summary>Flag to signal when clients should send ACKs</summary> |
152 | private bool m_sendAcks; | 153 | protected bool m_sendAcks; |
154 | |||
153 | /// <summary>Flag to signal when clients should send pings</summary> | 155 | /// <summary>Flag to signal when clients should send pings</summary> |
154 | private bool m_sendPing; | 156 | protected bool m_sendPing; |
155 | 157 | ||
156 | private ExpiringCache<IPEndPoint, Queue<UDPPacketBuffer>> m_pendingCache = new ExpiringCache<IPEndPoint, Queue<UDPPacketBuffer>>(); | 158 | private ExpiringCache<IPEndPoint, Queue<UDPPacketBuffer>> m_pendingCache = new ExpiringCache<IPEndPoint, Queue<UDPPacketBuffer>>(); |
157 | 159 | ||
158 | private int m_defaultRTO = 0; | 160 | private int m_defaultRTO = 0; |
159 | private int m_maxRTO = 0; | 161 | private int m_maxRTO = 0; |
160 | 162 | private int m_ackTimeout = 0; | |
163 | private int m_pausedAckTimeout = 0; | ||
161 | private bool m_disableFacelights = false; | 164 | private bool m_disableFacelights = false; |
162 | 165 | ||
163 | public Socket Server { get { return null; } } | 166 | public Socket Server { get { return null; } } |
164 | 167 | ||
165 | private int m_malformedCount = 0; // Guard against a spamming attack | 168 | private int m_malformedCount = 0; // Guard against a spamming attack |
166 | 169 | ||
170 | /// <summary> | ||
171 | /// Record current outgoing client for monitoring purposes. | ||
172 | /// </summary> | ||
173 | private IClientAPI m_currentOutgoingClient; | ||
174 | |||
175 | /// <summary> | ||
176 | /// Recording current incoming client for monitoring purposes. | ||
177 | /// </summary> | ||
178 | private IClientAPI m_currentIncomingClient; | ||
179 | |||
167 | public LLUDPServer(IPAddress listenIP, ref uint port, int proxyPortOffsetParm, bool allow_alternate_port, IConfigSource configSource, AgentCircuitManager circuitManager) | 180 | public LLUDPServer(IPAddress listenIP, ref uint port, int proxyPortOffsetParm, bool allow_alternate_port, IConfigSource configSource, AgentCircuitManager circuitManager) |
168 | : base(listenIP, (int)port) | 181 | : base(listenIP, (int)port) |
169 | { | 182 | { |
@@ -200,11 +213,15 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
200 | m_defaultRTO = config.GetInt("DefaultRTO", 0); | 213 | m_defaultRTO = config.GetInt("DefaultRTO", 0); |
201 | m_maxRTO = config.GetInt("MaxRTO", 0); | 214 | m_maxRTO = config.GetInt("MaxRTO", 0); |
202 | m_disableFacelights = config.GetBoolean("DisableFacelights", false); | 215 | m_disableFacelights = config.GetBoolean("DisableFacelights", false); |
216 | m_ackTimeout = 1000 * config.GetInt("AckTimeout", 60); | ||
217 | m_pausedAckTimeout = 1000 * config.GetInt("PausedAckTimeout", 300); | ||
203 | } | 218 | } |
204 | else | 219 | else |
205 | { | 220 | { |
206 | PrimUpdatesPerCallback = 100; | 221 | PrimUpdatesPerCallback = 100; |
207 | TextureSendLimit = 20; | 222 | TextureSendLimit = 20; |
223 | m_ackTimeout = 1000 * 60; // 1 minute | ||
224 | m_pausedAckTimeout = 1000 * 300; // 5 minutes | ||
208 | } | 225 | } |
209 | 226 | ||
210 | #region BinaryStats | 227 | #region BinaryStats |
@@ -241,19 +258,56 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
241 | if (m_scene == null) | 258 | if (m_scene == null) |
242 | throw new InvalidOperationException("[LLUDPSERVER]: Cannot LLUDPServer.Start() without an IScene reference"); | 259 | throw new InvalidOperationException("[LLUDPSERVER]: Cannot LLUDPServer.Start() without an IScene reference"); |
243 | 260 | ||
244 | m_log.Info("[LLUDPSERVER]: Starting the LLUDP server in " + (m_asyncPacketHandling ? "asynchronous" : "synchronous") + " mode"); | 261 | m_log.InfoFormat( |
262 | "[LLUDPSERVER]: Starting the LLUDP server in {0} mode", | ||
263 | m_asyncPacketHandling ? "asynchronous" : "synchronous"); | ||
245 | 264 | ||
246 | base.Start(m_recvBufferSize, m_asyncPacketHandling); | 265 | base.Start(m_recvBufferSize, m_asyncPacketHandling); |
247 | 266 | ||
248 | // Start the packet processing threads | 267 | // Start the packet processing threads |
249 | Watchdog.StartThread( | 268 | Watchdog.StartThread( |
250 | IncomingPacketHandler, "Incoming Packets (" + m_scene.RegionInfo.RegionName + ")", ThreadPriority.Normal, false, true); | 269 | IncomingPacketHandler, |
270 | string.Format("Incoming Packets ({0})", m_scene.RegionInfo.RegionName), | ||
271 | ThreadPriority.Normal, | ||
272 | false, | ||
273 | true, | ||
274 | GetWatchdogIncomingAlarmData, | ||
275 | Watchdog.DEFAULT_WATCHDOG_TIMEOUT_MS); | ||
276 | |||
251 | Watchdog.StartThread( | 277 | Watchdog.StartThread( |
252 | OutgoingPacketHandler, "Outgoing Packets (" + m_scene.RegionInfo.RegionName + ")", ThreadPriority.Normal, false, true); | 278 | OutgoingPacketHandler, |
279 | string.Format("Outgoing Packets ({0})", m_scene.RegionInfo.RegionName), | ||
280 | ThreadPriority.Normal, | ||
281 | false, | ||
282 | true, | ||
283 | GetWatchdogOutgoingAlarmData, | ||
284 | Watchdog.DEFAULT_WATCHDOG_TIMEOUT_MS); | ||
253 | 285 | ||
254 | m_elapsedMSSinceLastStatReport = Environment.TickCount; | 286 | m_elapsedMSSinceLastStatReport = Environment.TickCount; |
255 | } | 287 | } |
256 | 288 | ||
289 | /// <summary> | ||
290 | /// If the outgoing UDP thread times out, then return client that was being processed to help with debugging. | ||
291 | /// </summary> | ||
292 | /// <returns></returns> | ||
293 | private string GetWatchdogIncomingAlarmData() | ||
294 | { | ||
295 | return string.Format( | ||
296 | "Client is {0}", | ||
297 | m_currentIncomingClient != null ? m_currentIncomingClient.Name : "none"); | ||
298 | } | ||
299 | |||
300 | /// <summary> | ||
301 | /// If the outgoing UDP thread times out, then return client that was being processed to help with debugging. | ||
302 | /// </summary> | ||
303 | /// <returns></returns> | ||
304 | private string GetWatchdogOutgoingAlarmData() | ||
305 | { | ||
306 | return string.Format( | ||
307 | "Client is {0}", | ||
308 | m_currentOutgoingClient != null ? m_currentOutgoingClient.Name : "none"); | ||
309 | } | ||
310 | |||
257 | public new void Stop() | 311 | public new void Stop() |
258 | { | 312 | { |
259 | m_log.Info("[LLUDPSERVER]: Shutting down the LLUDP server for " + m_scene.RegionInfo.RegionName); | 313 | m_log.Info("[LLUDPSERVER]: Shutting down the LLUDP server for " + m_scene.RegionInfo.RegionName); |
@@ -487,19 +541,34 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
487 | SendPacket(udpClient, completePing, ThrottleOutPacketType.Unknown, false, null); | 541 | SendPacket(udpClient, completePing, ThrottleOutPacketType.Unknown, false, null); |
488 | } | 542 | } |
489 | 543 | ||
490 | public void HandleUnacked(LLUDPClient udpClient) | 544 | public void HandleUnacked(LLClientView client) |
491 | { | 545 | { |
546 | LLUDPClient udpClient = client.UDPClient; | ||
547 | |||
492 | if (!udpClient.IsConnected) | 548 | if (!udpClient.IsConnected) |
493 | return; | 549 | return; |
494 | 550 | ||
495 | // Disconnect an agent if no packets are received for some time | 551 | // Disconnect an agent if no packets are received for some time |
496 | //FIXME: Make 60 an .ini setting | 552 | int timeoutTicks = m_ackTimeout; |
497 | if ((Environment.TickCount & Int32.MaxValue) - udpClient.TickLastPacketReceived > 1000 * 60) | 553 | |
554 | // Allow more slack if the client is "paused" eg file upload dialogue is open | ||
555 | // Some sort of limit is needed in case the client crashes, loses its network connection | ||
556 | // or some other disaster prevents it from sendung the AgentResume | ||
557 | if (udpClient.IsPaused) | ||
558 | timeoutTicks = m_pausedAckTimeout; | ||
559 | |||
560 | if (client.IsActive && | ||
561 | (Environment.TickCount & Int32.MaxValue) - udpClient.TickLastPacketReceived > timeoutTicks) | ||
498 | { | 562 | { |
499 | m_log.Warn("[LLUDPSERVER]: Ack timeout, disconnecting " + udpClient.AgentID); | 563 | // We must set IsActive synchronously so that we can stop the packet loop reinvoking this method, even |
500 | StatsManager.SimExtraStats.AddAbnormalClientThreadTermination(); | 564 | // though it's set later on by LLClientView.Close() |
565 | client.IsActive = false; | ||
566 | |||
567 | // Fire this out on a different thread so that we don't hold up outgoing packet processing for | ||
568 | // everybody else if this is being called due to an ack timeout. | ||
569 | // This is the same as processing as the async process of a logout request. | ||
570 | Util.FireAndForget(o => DeactivateClientDueToTimeout(client)); | ||
501 | 571 | ||
502 | RemoveClient(udpClient); | ||
503 | return; | 572 | return; |
504 | } | 573 | } |
505 | 574 | ||
@@ -850,7 +919,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
850 | #endregion Ping Check Handling | 919 | #endregion Ping Check Handling |
851 | 920 | ||
852 | // Inbox insertion | 921 | // Inbox insertion |
853 | packetInbox.Enqueue(new IncomingPacket(udpClient, packet)); | 922 | packetInbox.Enqueue(new IncomingPacket((LLClientView)client, packet)); |
854 | } | 923 | } |
855 | 924 | ||
856 | #region BinaryStats | 925 | #region BinaryStats |
@@ -946,7 +1015,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
946 | UDPPacketBuffer buffer = (UDPPacketBuffer)array[0]; | 1015 | UDPPacketBuffer buffer = (UDPPacketBuffer)array[0]; |
947 | UseCircuitCodePacket uccp = (UseCircuitCodePacket)array[1]; | 1016 | UseCircuitCodePacket uccp = (UseCircuitCodePacket)array[1]; |
948 | 1017 | ||
949 | m_log.DebugFormat("[LLUDPSERVER]: Handling UseCircuitCode request from {0}", buffer.RemoteEndPoint); | 1018 | m_log.DebugFormat( |
1019 | "[LLUDPSERVER]: Handling UseCircuitCode request for circuit {0} to {1} from IP {2}", | ||
1020 | uccp.CircuitCode.Code, m_scene.RegionInfo.RegionName, buffer.RemoteEndPoint); | ||
950 | 1021 | ||
951 | remoteEndPoint = (IPEndPoint)buffer.RemoteEndPoint; | 1022 | remoteEndPoint = (IPEndPoint)buffer.RemoteEndPoint; |
952 | 1023 | ||
@@ -1001,8 +1072,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
1001 | { | 1072 | { |
1002 | // Don't create clients for unauthorized requesters. | 1073 | // Don't create clients for unauthorized requesters. |
1003 | m_log.WarnFormat( | 1074 | m_log.WarnFormat( |
1004 | "[LLUDPSERVER]: Connection request for client {0} connecting with unnotified circuit code {1} from {2}", | 1075 | "[LLUDPSERVER]: Ignoring connection request for {0} to {1} with unknown circuit code {2} from IP {3}", |
1005 | uccp.CircuitCode.ID, uccp.CircuitCode.Code, remoteEndPoint); | 1076 | uccp.CircuitCode.ID, m_scene.RegionInfo.RegionName, uccp.CircuitCode.Code, remoteEndPoint); |
1006 | lock (m_pendingCache) | 1077 | lock (m_pendingCache) |
1007 | m_pendingCache.Remove(remoteEndPoint); | 1078 | m_pendingCache.Remove(remoteEndPoint); |
1008 | } | 1079 | } |
@@ -1090,7 +1161,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
1090 | { | 1161 | { |
1091 | LLUDPClient udpClient = new LLUDPClient(this, ThrottleRates, m_throttle, circuitCode, agentID, remoteEndPoint, m_defaultRTO, m_maxRTO); | 1162 | LLUDPClient udpClient = new LLUDPClient(this, ThrottleRates, m_throttle, circuitCode, agentID, remoteEndPoint, m_defaultRTO, m_maxRTO); |
1092 | 1163 | ||
1093 | client = new LLClientView(remoteEndPoint, m_scene, this, udpClient, sessionInfo, agentID, sessionID, circuitCode); | 1164 | client = new LLClientView(m_scene, this, udpClient, sessionInfo, agentID, sessionID, circuitCode); |
1094 | client.OnLogout += LogoutHandler; | 1165 | client.OnLogout += LogoutHandler; |
1095 | 1166 | ||
1096 | ((LLClientView)client).DisableFacelights = m_disableFacelights; | 1167 | ((LLClientView)client).DisableFacelights = m_disableFacelights; |
@@ -1102,15 +1173,30 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
1102 | return client; | 1173 | return client; |
1103 | } | 1174 | } |
1104 | 1175 | ||
1105 | private void RemoveClient(LLUDPClient udpClient) | 1176 | /// <summary> |
1177 | /// Deactivates the client if we don't receive any packets within a certain amount of time (default 60 seconds). | ||
1178 | /// </summary> | ||
1179 | /// <remarks> | ||
1180 | /// If a connection is active then we will always receive packets even if nothing else is happening, due to | ||
1181 | /// regular client pings. | ||
1182 | /// </remarks> | ||
1183 | /// <param name='client'></param> | ||
1184 | private void DeactivateClientDueToTimeout(IClientAPI client) | ||
1106 | { | 1185 | { |
1107 | // Remove this client from the scene | 1186 | // We must set IsActive synchronously so that we can stop the packet loop reinvoking this method, even |
1108 | IClientAPI client; | 1187 | // though it's set later on by LLClientView.Close() |
1109 | if (m_scene.TryGetClient(udpClient.AgentID, out client)) | 1188 | client.IsActive = false; |
1110 | { | 1189 | |
1111 | client.IsLoggingOut = true; | 1190 | m_log.WarnFormat( |
1112 | client.Close(false); | 1191 | "[LLUDPSERVER]: Ack timeout, disconnecting {0} agent for {1} in {2}", |
1113 | } | 1192 | client.SceneAgent.IsChildAgent ? "child" : "root", client.Name, m_scene.RegionInfo.RegionName); |
1193 | |||
1194 | StatsManager.SimExtraStats.AddAbnormalClientThreadTermination(); | ||
1195 | |||
1196 | if (!client.SceneAgent.IsChildAgent) | ||
1197 | client.Kick("Simulator logged you out due to connection timeout"); | ||
1198 | |||
1199 | Util.FireAndForget(o => client.Close()); | ||
1114 | } | 1200 | } |
1115 | 1201 | ||
1116 | private void IncomingPacketHandler() | 1202 | private void IncomingPacketHandler() |
@@ -1219,6 +1305,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
1219 | // client. m_packetSent will be set to true if a packet is sent | 1305 | // client. m_packetSent will be set to true if a packet is sent |
1220 | m_scene.ForEachClient(clientPacketHandler); | 1306 | m_scene.ForEachClient(clientPacketHandler); |
1221 | 1307 | ||
1308 | m_currentOutgoingClient = null; | ||
1309 | |||
1222 | // If nothing was sent, sleep for the minimum amount of time before a | 1310 | // If nothing was sent, sleep for the minimum amount of time before a |
1223 | // token bucket could get more tokens | 1311 | // token bucket could get more tokens |
1224 | if (!m_packetSent) | 1312 | if (!m_packetSent) |
@@ -1235,18 +1323,21 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
1235 | Watchdog.RemoveThread(); | 1323 | Watchdog.RemoveThread(); |
1236 | } | 1324 | } |
1237 | 1325 | ||
1238 | private void ClientOutgoingPacketHandler(IClientAPI client) | 1326 | protected void ClientOutgoingPacketHandler(IClientAPI client) |
1239 | { | 1327 | { |
1328 | m_currentOutgoingClient = client; | ||
1329 | |||
1240 | try | 1330 | try |
1241 | { | 1331 | { |
1242 | if (client is LLClientView) | 1332 | if (client is LLClientView) |
1243 | { | 1333 | { |
1244 | LLUDPClient udpClient = ((LLClientView)client).UDPClient; | 1334 | LLClientView llClient = (LLClientView)client; |
1335 | LLUDPClient udpClient = llClient.UDPClient; | ||
1245 | 1336 | ||
1246 | if (udpClient.IsConnected) | 1337 | if (udpClient.IsConnected) |
1247 | { | 1338 | { |
1248 | if (m_resendUnacked) | 1339 | if (m_resendUnacked) |
1249 | HandleUnacked(udpClient); | 1340 | HandleUnacked(llClient); |
1250 | 1341 | ||
1251 | if (m_sendAcks) | 1342 | if (m_sendAcks) |
1252 | SendAcks(udpClient); | 1343 | SendAcks(udpClient); |
@@ -1262,8 +1353,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
1262 | } | 1353 | } |
1263 | catch (Exception ex) | 1354 | catch (Exception ex) |
1264 | { | 1355 | { |
1265 | m_log.Error("[LLUDPSERVER]: OutgoingPacketHandler iteration for " + client.Name + | 1356 | m_log.Error( |
1266 | " threw an exception: " + ex.Message, ex); | 1357 | string.Format("[LLUDPSERVER]: OutgoingPacketHandler iteration for {0} threw ", client.Name), ex); |
1267 | } | 1358 | } |
1268 | } | 1359 | } |
1269 | 1360 | ||
@@ -1289,11 +1380,14 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
1289 | { | 1380 | { |
1290 | nticks++; | 1381 | nticks++; |
1291 | watch1.Start(); | 1382 | watch1.Start(); |
1383 | m_currentOutgoingClient = client; | ||
1384 | |||
1292 | try | 1385 | try |
1293 | { | 1386 | { |
1294 | if (client is LLClientView) | 1387 | if (client is LLClientView) |
1295 | { | 1388 | { |
1296 | LLUDPClient udpClient = ((LLClientView)client).UDPClient; | 1389 | LLClientView llClient = (LLClientView)client; |
1390 | LLUDPClient udpClient = llClient.UDPClient; | ||
1297 | 1391 | ||
1298 | if (udpClient.IsConnected) | 1392 | if (udpClient.IsConnected) |
1299 | { | 1393 | { |
@@ -1302,7 +1396,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
1302 | nticksUnack++; | 1396 | nticksUnack++; |
1303 | watch2.Start(); | 1397 | watch2.Start(); |
1304 | 1398 | ||
1305 | HandleUnacked(udpClient); | 1399 | HandleUnacked(llClient); |
1306 | 1400 | ||
1307 | watch2.Stop(); | 1401 | watch2.Stop(); |
1308 | avgResendUnackedTicks = (nticksUnack - 1)/(float)nticksUnack * avgResendUnackedTicks + (watch2.ElapsedTicks / (float)nticksUnack); | 1402 | avgResendUnackedTicks = (nticksUnack - 1)/(float)nticksUnack * avgResendUnackedTicks + (watch2.ElapsedTicks / (float)nticksUnack); |
@@ -1373,23 +1467,15 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
1373 | 1467 | ||
1374 | #endregion | 1468 | #endregion |
1375 | 1469 | ||
1376 | private void ProcessInPacket(object state) | 1470 | private void ProcessInPacket(IncomingPacket incomingPacket) |
1377 | { | 1471 | { |
1378 | IncomingPacket incomingPacket = (IncomingPacket)state; | ||
1379 | Packet packet = incomingPacket.Packet; | 1472 | Packet packet = incomingPacket.Packet; |
1380 | LLUDPClient udpClient = incomingPacket.Client; | 1473 | LLClientView client = incomingPacket.Client; |
1381 | IClientAPI client; | ||
1382 | 1474 | ||
1383 | // Sanity check | 1475 | if (client.IsActive) |
1384 | if (packet == null || udpClient == null) | ||
1385 | { | 1476 | { |
1386 | m_log.WarnFormat("[LLUDPSERVER]: Processing a packet with incomplete state. Packet=\"{0}\", UDPClient=\"{1}\"", | 1477 | m_currentIncomingClient = client; |
1387 | packet, udpClient); | ||
1388 | } | ||
1389 | 1478 | ||
1390 | // Make sure this client is still alive | ||
1391 | if (m_scene.TryGetClient(udpClient.AgentID, out client)) | ||
1392 | { | ||
1393 | try | 1479 | try |
1394 | { | 1480 | { |
1395 | // Process this packet | 1481 | // Process this packet |
@@ -1404,21 +1490,34 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
1404 | catch (Exception e) | 1490 | catch (Exception e) |
1405 | { | 1491 | { |
1406 | // Don't let a failure in an individual client thread crash the whole sim. | 1492 | // Don't let a failure in an individual client thread crash the whole sim. |
1407 | m_log.ErrorFormat("[LLUDPSERVER]: Client packet handler for {0} for packet {1} threw an exception", udpClient.AgentID, packet.Type); | 1493 | m_log.Error( |
1408 | m_log.Error(e.Message, e); | 1494 | string.Format( |
1495 | "[LLUDPSERVER]: Client packet handler for {0} for packet {1} threw ", | ||
1496 | client.Name, packet.Type), | ||
1497 | e); | ||
1498 | } | ||
1499 | finally | ||
1500 | { | ||
1501 | m_currentIncomingClient = null; | ||
1409 | } | 1502 | } |
1410 | } | 1503 | } |
1411 | else | 1504 | else |
1412 | { | 1505 | { |
1413 | m_log.DebugFormat("[LLUDPSERVER]: Dropping incoming {0} packet for dead client {1}", packet.Type, udpClient.AgentID); | 1506 | m_log.DebugFormat( |
1507 | "[LLUDPSERVER]: Dropped incoming {0} for dead client {1} in {2}", | ||
1508 | packet.Type, client.Name, m_scene.RegionInfo.RegionName); | ||
1414 | } | 1509 | } |
1415 | } | 1510 | } |
1416 | 1511 | ||
1417 | protected void LogoutHandler(IClientAPI client) | 1512 | protected void LogoutHandler(IClientAPI client) |
1418 | { | 1513 | { |
1419 | client.SendLogoutPacket(); | 1514 | client.SendLogoutPacket(); |
1420 | if (client.IsActive) | 1515 | |
1421 | RemoveClient(((LLClientView)client).UDPClient); | 1516 | if (!client.IsLoggingOut) |
1517 | { | ||
1518 | client.IsLoggingOut = true; | ||
1519 | client.Close(); | ||
1520 | } | ||
1422 | } | 1521 | } |
1423 | } | 1522 | } |
1424 | } | 1523 | } |
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/Tests/BasicCircuitTests.cs b/OpenSim/Region/ClientStack/Linden/UDP/Tests/BasicCircuitTests.cs index a575e36..109a8e1 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/Tests/BasicCircuitTests.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/Tests/BasicCircuitTests.cs | |||
@@ -45,6 +45,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests | |||
45 | [TestFixture] | 45 | [TestFixture] |
46 | public class BasicCircuitTests | 46 | public class BasicCircuitTests |
47 | { | 47 | { |
48 | private Scene m_scene; | ||
49 | private TestLLUDPServer m_udpServer; | ||
50 | |||
48 | [TestFixtureSetUp] | 51 | [TestFixtureSetUp] |
49 | public void FixtureInit() | 52 | public void FixtureInit() |
50 | { | 53 | { |
@@ -61,83 +64,18 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests | |||
61 | Util.FireAndForgetMethod = Util.DefaultFireAndForgetMethod; | 64 | Util.FireAndForgetMethod = Util.DefaultFireAndForgetMethod; |
62 | } | 65 | } |
63 | 66 | ||
64 | // /// <summary> | 67 | [SetUp] |
65 | // /// Add a client for testing | 68 | public void SetUp() |
66 | // /// </summary> | 69 | { |
67 | // /// <param name="scene"></param> | 70 | m_scene = new SceneHelpers().SetupScene(); |
68 | // /// <param name="testLLUDPServer"></param> | 71 | } |
69 | // /// <param name="testPacketServer"></param> | ||
70 | // /// <param name="acm">Agent circuit manager used in setting up the stack</param> | ||
71 | // protected void SetupStack( | ||
72 | // IScene scene, out TestLLUDPServer testLLUDPServer, out TestLLPacketServer testPacketServer, | ||
73 | // out AgentCircuitManager acm) | ||
74 | // { | ||
75 | // IConfigSource configSource = new IniConfigSource(); | ||
76 | // ClientStackUserSettings userSettings = new ClientStackUserSettings(); | ||
77 | // testLLUDPServer = new TestLLUDPServer(); | ||
78 | // acm = new AgentCircuitManager(); | ||
79 | // | ||
80 | // uint port = 666; | ||
81 | // testLLUDPServer.Initialise(null, ref port, 0, false, configSource, acm); | ||
82 | // testPacketServer = new TestLLPacketServer(testLLUDPServer, userSettings); | ||
83 | // testLLUDPServer.LocalScene = scene; | ||
84 | // } | ||
85 | |||
86 | // /// <summary> | ||
87 | // /// Set up a client for tests which aren't concerned with this process itself and where only one client is being | ||
88 | // /// tested | ||
89 | // /// </summary> | ||
90 | // /// <param name="circuitCode"></param> | ||
91 | // /// <param name="epSender"></param> | ||
92 | // /// <param name="testLLUDPServer"></param> | ||
93 | // /// <param name="acm"></param> | ||
94 | // protected void AddClient( | ||
95 | // uint circuitCode, EndPoint epSender, TestLLUDPServer testLLUDPServer, AgentCircuitManager acm) | ||
96 | // { | ||
97 | // UUID myAgentUuid = UUID.Parse("00000000-0000-0000-0000-000000000001"); | ||
98 | // UUID mySessionUuid = UUID.Parse("00000000-0000-0000-0000-000000000002"); | ||
99 | // | ||
100 | // AddClient(circuitCode, epSender, myAgentUuid, mySessionUuid, testLLUDPServer, acm); | ||
101 | // } | ||
102 | |||
103 | // /// <summary> | ||
104 | // /// Set up a client for tests which aren't concerned with this process itself | ||
105 | // /// </summary> | ||
106 | // /// <param name="circuitCode"></param> | ||
107 | // /// <param name="epSender"></param> | ||
108 | // /// <param name="agentId"></param> | ||
109 | // /// <param name="sessionId"></param> | ||
110 | // /// <param name="testLLUDPServer"></param> | ||
111 | // /// <param name="acm"></param> | ||
112 | // protected void AddClient( | ||
113 | // uint circuitCode, EndPoint epSender, UUID agentId, UUID sessionId, | ||
114 | // TestLLUDPServer testLLUDPServer, AgentCircuitManager acm) | ||
115 | // { | ||
116 | // AgentCircuitData acd = new AgentCircuitData(); | ||
117 | // acd.AgentID = agentId; | ||
118 | // acd.SessionID = sessionId; | ||
119 | // | ||
120 | // UseCircuitCodePacket uccp = new UseCircuitCodePacket(); | ||
121 | // | ||
122 | // UseCircuitCodePacket.CircuitCodeBlock uccpCcBlock | ||
123 | // = new UseCircuitCodePacket.CircuitCodeBlock(); | ||
124 | // uccpCcBlock.Code = circuitCode; | ||
125 | // uccpCcBlock.ID = agentId; | ||
126 | // uccpCcBlock.SessionID = sessionId; | ||
127 | // uccp.CircuitCode = uccpCcBlock; | ||
128 | // | ||
129 | // acm.AddNewCircuit(circuitCode, acd); | ||
130 | // | ||
131 | // testLLUDPServer.LoadReceive(uccp, epSender); | ||
132 | // testLLUDPServer.ReceiveData(null); | ||
133 | // } | ||
134 | 72 | ||
135 | /// <summary> | 73 | /// <summary> |
136 | /// Build an object name packet for test purposes | 74 | /// Build an object name packet for test purposes |
137 | /// </summary> | 75 | /// </summary> |
138 | /// <param name="objectLocalId"></param> | 76 | /// <param name="objectLocalId"></param> |
139 | /// <param name="objectName"></param> | 77 | /// <param name="objectName"></param> |
140 | protected ObjectNamePacket BuildTestObjectNamePacket(uint objectLocalId, string objectName) | 78 | private ObjectNamePacket BuildTestObjectNamePacket(uint objectLocalId, string objectName) |
141 | { | 79 | { |
142 | ObjectNamePacket onp = new ObjectNamePacket(); | 80 | ObjectNamePacket onp = new ObjectNamePacket(); |
143 | ObjectNamePacket.ObjectDataBlock odb = new ObjectNamePacket.ObjectDataBlock(); | 81 | ObjectNamePacket.ObjectDataBlock odb = new ObjectNamePacket.ObjectDataBlock(); |
@@ -148,6 +86,55 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests | |||
148 | 86 | ||
149 | return onp; | 87 | return onp; |
150 | } | 88 | } |
89 | |||
90 | private void AddUdpServer() | ||
91 | { | ||
92 | AddUdpServer(new IniConfigSource()); | ||
93 | } | ||
94 | |||
95 | private void AddUdpServer(IniConfigSource configSource) | ||
96 | { | ||
97 | uint port = 0; | ||
98 | AgentCircuitManager acm = m_scene.AuthenticateHandler; | ||
99 | |||
100 | m_udpServer = new TestLLUDPServer(IPAddress.Any, ref port, 0, false, configSource, acm); | ||
101 | m_udpServer.AddScene(m_scene); | ||
102 | } | ||
103 | |||
104 | /// <summary> | ||
105 | /// Used by tests that aren't testing this stage. | ||
106 | /// </summary> | ||
107 | private ScenePresence AddClient() | ||
108 | { | ||
109 | UUID myAgentUuid = TestHelpers.ParseTail(0x1); | ||
110 | UUID mySessionUuid = TestHelpers.ParseTail(0x2); | ||
111 | uint myCircuitCode = 123456; | ||
112 | IPEndPoint testEp = new IPEndPoint(IPAddress.Loopback, 999); | ||
113 | |||
114 | UseCircuitCodePacket uccp = new UseCircuitCodePacket(); | ||
115 | |||
116 | UseCircuitCodePacket.CircuitCodeBlock uccpCcBlock | ||
117 | = new UseCircuitCodePacket.CircuitCodeBlock(); | ||
118 | uccpCcBlock.Code = myCircuitCode; | ||
119 | uccpCcBlock.ID = myAgentUuid; | ||
120 | uccpCcBlock.SessionID = mySessionUuid; | ||
121 | uccp.CircuitCode = uccpCcBlock; | ||
122 | |||
123 | byte[] uccpBytes = uccp.ToBytes(); | ||
124 | UDPPacketBuffer upb = new UDPPacketBuffer(testEp, uccpBytes.Length); | ||
125 | upb.DataLength = uccpBytes.Length; // God knows why this isn't set by the constructor. | ||
126 | Buffer.BlockCopy(uccpBytes, 0, upb.Data, 0, uccpBytes.Length); | ||
127 | |||
128 | AgentCircuitData acd = new AgentCircuitData(); | ||
129 | acd.AgentID = myAgentUuid; | ||
130 | acd.SessionID = mySessionUuid; | ||
131 | |||
132 | m_scene.AuthenticateHandler.AddNewCircuit(myCircuitCode, acd); | ||
133 | |||
134 | m_udpServer.PacketReceived(upb); | ||
135 | |||
136 | return m_scene.GetScenePresence(myAgentUuid); | ||
137 | } | ||
151 | 138 | ||
152 | /// <summary> | 139 | /// <summary> |
153 | /// Test adding a client to the stack | 140 | /// Test adding a client to the stack |
@@ -158,19 +145,13 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests | |||
158 | TestHelpers.InMethod(); | 145 | TestHelpers.InMethod(); |
159 | // XmlConfigurator.Configure(); | 146 | // XmlConfigurator.Configure(); |
160 | 147 | ||
161 | TestScene scene = SceneHelpers.SetupScene(); | 148 | AddUdpServer(); |
162 | uint myCircuitCode = 123456; | 149 | |
163 | UUID myAgentUuid = TestHelpers.ParseTail(0x1); | 150 | UUID myAgentUuid = TestHelpers.ParseTail(0x1); |
164 | UUID mySessionUuid = TestHelpers.ParseTail(0x2); | 151 | UUID mySessionUuid = TestHelpers.ParseTail(0x2); |
152 | uint myCircuitCode = 123456; | ||
165 | IPEndPoint testEp = new IPEndPoint(IPAddress.Loopback, 999); | 153 | IPEndPoint testEp = new IPEndPoint(IPAddress.Loopback, 999); |
166 | 154 | ||
167 | uint port = 0; | ||
168 | AgentCircuitManager acm = scene.AuthenticateHandler; | ||
169 | |||
170 | TestLLUDPServer llUdpServer | ||
171 | = new TestLLUDPServer(IPAddress.Any, ref port, 0, false, new IniConfigSource(), acm); | ||
172 | llUdpServer.AddScene(scene); | ||
173 | |||
174 | UseCircuitCodePacket uccp = new UseCircuitCodePacket(); | 155 | UseCircuitCodePacket uccp = new UseCircuitCodePacket(); |
175 | 156 | ||
176 | UseCircuitCodePacket.CircuitCodeBlock uccpCcBlock | 157 | UseCircuitCodePacket.CircuitCodeBlock uccpCcBlock |
@@ -185,26 +166,26 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests | |||
185 | upb.DataLength = uccpBytes.Length; // God knows why this isn't set by the constructor. | 166 | upb.DataLength = uccpBytes.Length; // God knows why this isn't set by the constructor. |
186 | Buffer.BlockCopy(uccpBytes, 0, upb.Data, 0, uccpBytes.Length); | 167 | Buffer.BlockCopy(uccpBytes, 0, upb.Data, 0, uccpBytes.Length); |
187 | 168 | ||
188 | llUdpServer.PacketReceived(upb); | 169 | m_udpServer.PacketReceived(upb); |
189 | 170 | ||
190 | // Presence shouldn't exist since the circuit manager doesn't know about this circuit for authentication yet | 171 | // Presence shouldn't exist since the circuit manager doesn't know about this circuit for authentication yet |
191 | Assert.That(scene.GetScenePresence(myAgentUuid), Is.Null); | 172 | Assert.That(m_scene.GetScenePresence(myAgentUuid), Is.Null); |
192 | 173 | ||
193 | AgentCircuitData acd = new AgentCircuitData(); | 174 | AgentCircuitData acd = new AgentCircuitData(); |
194 | acd.AgentID = myAgentUuid; | 175 | acd.AgentID = myAgentUuid; |
195 | acd.SessionID = mySessionUuid; | 176 | acd.SessionID = mySessionUuid; |
196 | 177 | ||
197 | acm.AddNewCircuit(myCircuitCode, acd); | 178 | m_scene.AuthenticateHandler.AddNewCircuit(myCircuitCode, acd); |
198 | 179 | ||
199 | llUdpServer.PacketReceived(upb); | 180 | m_udpServer.PacketReceived(upb); |
200 | 181 | ||
201 | // Should succeed now | 182 | // Should succeed now |
202 | ScenePresence sp = scene.GetScenePresence(myAgentUuid); | 183 | ScenePresence sp = m_scene.GetScenePresence(myAgentUuid); |
203 | Assert.That(sp.UUID, Is.EqualTo(myAgentUuid)); | 184 | Assert.That(sp.UUID, Is.EqualTo(myAgentUuid)); |
204 | 185 | ||
205 | Assert.That(llUdpServer.PacketsSent.Count, Is.EqualTo(1)); | 186 | Assert.That(m_udpServer.PacketsSent.Count, Is.EqualTo(1)); |
206 | 187 | ||
207 | Packet packet = llUdpServer.PacketsSent[0]; | 188 | Packet packet = m_udpServer.PacketsSent[0]; |
208 | Assert.That(packet, Is.InstanceOf(typeof(PacketAckPacket))); | 189 | Assert.That(packet, Is.InstanceOf(typeof(PacketAckPacket))); |
209 | 190 | ||
210 | PacketAckPacket ackPacket = packet as PacketAckPacket; | 191 | PacketAckPacket ackPacket = packet as PacketAckPacket; |
@@ -212,6 +193,26 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests | |||
212 | Assert.That(ackPacket.Packets[0].ID, Is.EqualTo(0)); | 193 | Assert.That(ackPacket.Packets[0].ID, Is.EqualTo(0)); |
213 | } | 194 | } |
214 | 195 | ||
196 | [Test] | ||
197 | public void TestLogoutClientDueToAck() | ||
198 | { | ||
199 | TestHelpers.InMethod(); | ||
200 | // TestHelpers.EnableLogging(); | ||
201 | |||
202 | IniConfigSource ics = new IniConfigSource(); | ||
203 | IConfig config = ics.AddConfig("ClientStack.LindenUDP"); | ||
204 | config.Set("AckTimeout", -1); | ||
205 | AddUdpServer(ics); | ||
206 | |||
207 | ScenePresence sp = AddClient(); | ||
208 | m_udpServer.ClientOutgoingPacketHandler(sp.ControllingClient, true, false, false); | ||
209 | |||
210 | ScenePresence spAfterAckTimeout = m_scene.GetScenePresence(sp.UUID); | ||
211 | Assert.That(spAfterAckTimeout, Is.Null); | ||
212 | |||
213 | // TestHelpers.DisableLogging(); | ||
214 | } | ||
215 | |||
215 | // /// <summary> | 216 | // /// <summary> |
216 | // /// Test removing a client from the stack | 217 | // /// Test removing a client from the stack |
217 | // /// </summary> | 218 | // /// </summary> |
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/Tests/LLImageManagerTests.cs b/OpenSim/Region/ClientStack/Linden/UDP/Tests/LLImageManagerTests.cs index 1b68d68..5fcf376 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/Tests/LLImageManagerTests.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/Tests/LLImageManagerTests.cs | |||
@@ -79,7 +79,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests | |||
79 | 79 | ||
80 | J2KDecoderModule j2kdm = new J2KDecoderModule(); | 80 | J2KDecoderModule j2kdm = new J2KDecoderModule(); |
81 | 81 | ||
82 | scene = SceneHelpers.SetupScene(); | 82 | SceneHelpers sceneHelpers = new SceneHelpers(); |
83 | scene = sceneHelpers.SetupScene(); | ||
83 | SceneHelpers.SetupSceneModules(scene, j2kdm); | 84 | SceneHelpers.SetupSceneModules(scene, j2kdm); |
84 | 85 | ||
85 | tc = new TestClient(SceneHelpers.GenerateAgentData(userId), scene); | 86 | tc = new TestClient(SceneHelpers.GenerateAgentData(userId), scene); |
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/Tests/MockScene.cs b/OpenSim/Region/ClientStack/Linden/UDP/Tests/MockScene.cs index d76927b..119a677 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/Tests/MockScene.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/Tests/MockScene.cs | |||
@@ -44,9 +44,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests | |||
44 | } | 44 | } |
45 | protected int m_objectNameCallsReceived; | 45 | protected int m_objectNameCallsReceived; |
46 | 46 | ||
47 | public MockScene() | 47 | public MockScene() : base(new RegionInfo(1000, 1000, null, null)) |
48 | { | 48 | { |
49 | m_regInfo = new RegionInfo(1000, 1000, null, null); | ||
50 | m_regStatus = RegionStatus.Up; | 49 | m_regStatus = RegionStatus.Up; |
51 | } | 50 | } |
52 | 51 | ||
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/Tests/TestLLUDPServer.cs b/OpenSim/Region/ClientStack/Linden/UDP/Tests/TestLLUDPServer.cs index 0302385..27b9e5b 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/Tests/TestLLUDPServer.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/Tests/TestLLUDPServer.cs | |||
@@ -59,6 +59,15 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests | |||
59 | PacketsSent.Add(packet); | 59 | PacketsSent.Add(packet); |
60 | } | 60 | } |
61 | 61 | ||
62 | public void ClientOutgoingPacketHandler(IClientAPI client, bool resendUnacked, bool sendAcks, bool sendPing) | ||
63 | { | ||
64 | m_resendUnacked = resendUnacked; | ||
65 | m_sendAcks = sendAcks; | ||
66 | m_sendPing = sendPing; | ||
67 | |||
68 | ClientOutgoingPacketHandler(client); | ||
69 | } | ||
70 | |||
62 | //// /// <summary> | 71 | //// /// <summary> |
63 | //// /// The chunks of data to pass to the LLUDPServer when it calls EndReceive | 72 | //// /// The chunks of data to pass to the LLUDPServer when it calls EndReceive |
64 | //// /// </summary> | 73 | //// /// </summary> |