diff options
Diffstat (limited to 'OpenSim/Region/ClientStack/Linden/UDP')
-rw-r--r-- | OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs | 61 | ||||
-rw-r--r-- | OpenSim/Region/ClientStack/Linden/UDP/LLUDPClient.cs | 3 | ||||
-rw-r--r-- | OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs | 31 |
3 files changed, 62 insertions, 33 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs index ad9074c..f7bb817 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs | |||
@@ -41,7 +41,7 @@ using OpenMetaverse.Messages.Linden; | |||
41 | using OpenMetaverse.StructuredData; | 41 | using OpenMetaverse.StructuredData; |
42 | using OpenSim.Framework; | 42 | using OpenSim.Framework; |
43 | using OpenSim.Framework.Client; | 43 | using OpenSim.Framework.Client; |
44 | using OpenSim.Framework.Statistics; | 44 | using OpenSim.Framework.Monitoring; |
45 | using OpenSim.Region.Framework.Interfaces; | 45 | using OpenSim.Region.Framework.Interfaces; |
46 | using OpenSim.Region.Framework.Scenes; | 46 | using OpenSim.Region.Framework.Scenes; |
47 | using OpenSim.Services.Interfaces; | 47 | using OpenSim.Services.Interfaces; |
@@ -355,8 +355,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
355 | private int m_animationSequenceNumber = 1; | 355 | private int m_animationSequenceNumber = 1; |
356 | private bool m_SendLogoutPacketWhenClosing = true; | 356 | private bool m_SendLogoutPacketWhenClosing = true; |
357 | private AgentUpdateArgs lastarg; | 357 | private AgentUpdateArgs lastarg; |
358 | private bool m_IsActive = true; | ||
359 | private bool m_IsLoggingOut = false; | ||
360 | 358 | ||
361 | protected Dictionary<PacketType, PacketProcessor> m_packetHandlers = new Dictionary<PacketType, PacketProcessor>(); | 359 | protected Dictionary<PacketType, PacketProcessor> m_packetHandlers = new Dictionary<PacketType, PacketProcessor>(); |
362 | protected Dictionary<string, GenericMessage> m_genericPacketHandlers = new Dictionary<string, GenericMessage>(); //PauPaw:Local Generic Message handlers | 360 | protected Dictionary<string, GenericMessage> m_genericPacketHandlers = new Dictionary<string, GenericMessage>(); //PauPaw:Local Generic Message handlers |
@@ -428,16 +426,19 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
428 | public uint CircuitCode { get { return m_circuitCode; } } | 426 | public uint CircuitCode { get { return m_circuitCode; } } |
429 | public int MoneyBalance { get { return m_moneyBalance; } } | 427 | public int MoneyBalance { get { return m_moneyBalance; } } |
430 | public int NextAnimationSequenceNumber { get { return m_animationSequenceNumber++; } } | 428 | public int NextAnimationSequenceNumber { get { return m_animationSequenceNumber++; } } |
431 | public bool IsActive | 429 | |
432 | { | 430 | /// <summary> |
433 | get { return m_IsActive; } | 431 | /// As well as it's function in IClientAPI, in LLClientView we are locking on this property in order to |
434 | set { m_IsActive = value; } | 432 | /// prevent race conditions by different threads calling Close(). |
435 | } | 433 | /// </summary> |
436 | public bool IsLoggingOut | 434 | public bool IsActive { get; set; } |
437 | { | 435 | |
438 | get { return m_IsLoggingOut; } | 436 | /// <summary> |
439 | set { m_IsLoggingOut = value; } | 437 | /// Used to synchronise threads when client is being closed. |
440 | } | 438 | /// </summary> |
439 | public Object CloseSyncLock { get; private set; } | ||
440 | |||
441 | public bool IsLoggingOut { get; set; } | ||
441 | 442 | ||
442 | public bool DisableFacelights | 443 | public bool DisableFacelights |
443 | { | 444 | { |
@@ -462,6 +463,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
462 | { | 463 | { |
463 | // DebugPacketLevel = 1; | 464 | // DebugPacketLevel = 1; |
464 | 465 | ||
466 | CloseSyncLock = new Object(); | ||
467 | |||
465 | RegisterInterface<IClientIM>(this); | 468 | RegisterInterface<IClientIM>(this); |
466 | RegisterInterface<IClientInventory>(this); | 469 | RegisterInterface<IClientInventory>(this); |
467 | RegisterInterface<IClientChat>(this); | 470 | RegisterInterface<IClientChat>(this); |
@@ -494,13 +497,15 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
494 | m_prioritizer = new Prioritizer(m_scene); | 497 | m_prioritizer = new Prioritizer(m_scene); |
495 | 498 | ||
496 | RegisterLocalPacketHandlers(); | 499 | RegisterLocalPacketHandlers(); |
500 | |||
501 | IsActive = true; | ||
497 | } | 502 | } |
498 | 503 | ||
499 | #region Client Methods | 504 | #region Client Methods |
500 | 505 | ||
501 | 506 | ||
502 | /// <summary> | 507 | /// <summary> |
503 | /// Shut down the client view | 508 | /// Close down the client view |
504 | /// </summary> | 509 | /// </summary> |
505 | public void Close() | 510 | public void Close() |
506 | { | 511 | { |
@@ -513,7 +518,29 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
513 | public void Close(bool sendStop) | 518 | public void Close(bool sendStop) |
514 | { | 519 | { |
515 | IsActive = false; | 520 | IsActive = false; |
521 | // We lock here to prevent race conditions between two threads calling close simultaneously (e.g. | ||
522 | // a simultaneous relog just as a client is being closed out due to no packet ack from the old connection. | ||
523 | lock (CloseSyncLock) | ||
524 | { | ||
525 | if (!IsActive) | ||
526 | return; | ||
527 | |||
528 | IsActive = false; | ||
529 | CloseWithoutChecks(sendStop); | ||
530 | } | ||
531 | } | ||
516 | 532 | ||
533 | /// <summary> | ||
534 | /// Closes down the client view without first checking whether it is active. | ||
535 | /// </summary> | ||
536 | /// <remarks> | ||
537 | /// This exists because LLUDPServer has to set IsActive = false in earlier synchronous code before calling | ||
538 | /// CloseWithoutIsActiveCheck asynchronously. | ||
539 | /// | ||
540 | /// Callers must lock ClosingSyncLock before calling. | ||
541 | /// </remarks> | ||
542 | public void CloseWithoutChecks(bool sendStop) | ||
543 | { | ||
517 | m_log.DebugFormat( | 544 | m_log.DebugFormat( |
518 | "[CLIENT]: Close has been called for {0} attached to scene {1}", | 545 | "[CLIENT]: Close has been called for {0} attached to scene {1}", |
519 | Name, m_scene.RegionInfo.RegionName); | 546 | Name, m_scene.RegionInfo.RegionName); |
@@ -3634,7 +3661,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
3634 | 3661 | ||
3635 | public void SendCoarseLocationUpdate(List<UUID> users, List<Vector3> CoarseLocations) | 3662 | public void SendCoarseLocationUpdate(List<UUID> users, List<Vector3> CoarseLocations) |
3636 | { | 3663 | { |
3637 | if (!IsActive) return; // We don't need to update inactive clients. | 3664 | // We don't need to update inactive clients. |
3665 | if (!IsActive) | ||
3666 | return; | ||
3638 | 3667 | ||
3639 | CoarseLocationUpdatePacket loc = (CoarseLocationUpdatePacket)PacketPool.Instance.GetPacket(PacketType.CoarseLocationUpdate); | 3668 | CoarseLocationUpdatePacket loc = (CoarseLocationUpdatePacket)PacketPool.Instance.GetPacket(PacketType.CoarseLocationUpdate); |
3640 | loc.Header.Reliable = false; | 3669 | loc.Header.Reliable = false; |
@@ -5267,7 +5296,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
5267 | AddLocalPacketHandler(PacketType.ChatFromViewer, HandleChatFromViewer); | 5296 | AddLocalPacketHandler(PacketType.ChatFromViewer, HandleChatFromViewer); |
5268 | AddLocalPacketHandler(PacketType.AvatarPropertiesUpdate, HandlerAvatarPropertiesUpdate); | 5297 | AddLocalPacketHandler(PacketType.AvatarPropertiesUpdate, HandlerAvatarPropertiesUpdate); |
5269 | AddLocalPacketHandler(PacketType.ScriptDialogReply, HandlerScriptDialogReply); | 5298 | AddLocalPacketHandler(PacketType.ScriptDialogReply, HandlerScriptDialogReply); |
5270 | AddLocalPacketHandler(PacketType.ImprovedInstantMessage, HandlerImprovedInstantMessage, false); | 5299 | AddLocalPacketHandler(PacketType.ImprovedInstantMessage, HandlerImprovedInstantMessage); |
5271 | AddLocalPacketHandler(PacketType.AcceptFriendship, HandlerAcceptFriendship); | 5300 | AddLocalPacketHandler(PacketType.AcceptFriendship, HandlerAcceptFriendship); |
5272 | AddLocalPacketHandler(PacketType.DeclineFriendship, HandlerDeclineFriendship); | 5301 | AddLocalPacketHandler(PacketType.DeclineFriendship, HandlerDeclineFriendship); |
5273 | AddLocalPacketHandler(PacketType.TerminateFriendship, HandlerTerminateFriendship); | 5302 | AddLocalPacketHandler(PacketType.TerminateFriendship, HandlerTerminateFriendship); |
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPClient.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPClient.cs index ae72175..c472176 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPClient.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPClient.cs | |||
@@ -279,7 +279,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
279 | public string GetStats() | 279 | public string GetStats() |
280 | { | 280 | { |
281 | return string.Format( | 281 | return string.Format( |
282 | "{0,7} {1,7} {2,7} {3,9} {4,7} {5,7} {6,7} {7,7} {8,7} {9,8} {10,7} {11,7}", | 282 | "{0,7} {1,7} {2,7} {3,9} {4,7} {5,7} {6,7} {7,7} {8,7} {9,8} {10,7} {11,7} {12,7}", |
283 | Util.EnvironmentTickCountSubtract(TickLastPacketReceived), | ||
283 | PacketsReceived, | 284 | PacketsReceived, |
284 | PacketsSent, | 285 | PacketsSent, |
285 | PacketsResent, | 286 | PacketsResent, |
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs index b09f607..6c2e71b 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs | |||
@@ -37,7 +37,7 @@ using log4net; | |||
37 | using Nini.Config; | 37 | using Nini.Config; |
38 | using OpenMetaverse.Packets; | 38 | using OpenMetaverse.Packets; |
39 | using OpenSim.Framework; | 39 | using OpenSim.Framework; |
40 | using OpenSim.Framework.Statistics; | 40 | using OpenSim.Framework.Monitoring; |
41 | using OpenSim.Region.Framework.Scenes; | 41 | using OpenSim.Region.Framework.Scenes; |
42 | using OpenMetaverse; | 42 | using OpenMetaverse; |
43 | 43 | ||
@@ -1181,22 +1181,21 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
1181 | /// regular client pings. | 1181 | /// regular client pings. |
1182 | /// </remarks> | 1182 | /// </remarks> |
1183 | /// <param name='client'></param> | 1183 | /// <param name='client'></param> |
1184 | private void DeactivateClientDueToTimeout(IClientAPI client) | 1184 | private void DeactivateClientDueToTimeout(LLClientView client) |
1185 | { | 1185 | { |
1186 | // We must set IsActive synchronously so that we can stop the packet loop reinvoking this method, even | 1186 | lock (client.CloseSyncLock) |
1187 | // though it's set later on by LLClientView.Close() | 1187 | { |
1188 | client.IsActive = false; | 1188 | m_log.WarnFormat( |
1189 | 1189 | "[LLUDPSERVER]: Ack timeout, disconnecting {0} agent for {1} in {2}", | |
1190 | m_log.WarnFormat( | 1190 | client.SceneAgent.IsChildAgent ? "child" : "root", client.Name, m_scene.RegionInfo.RegionName); |
1191 | "[LLUDPSERVER]: Ack timeout, disconnecting {0} agent for {1} in {2}", | 1191 | |
1192 | client.SceneAgent.IsChildAgent ? "child" : "root", client.Name, m_scene.RegionInfo.RegionName); | 1192 | StatsManager.SimExtraStats.AddAbnormalClientThreadTermination(); |
1193 | 1193 | ||
1194 | StatsManager.SimExtraStats.AddAbnormalClientThreadTermination(); | 1194 | if (!client.SceneAgent.IsChildAgent) |
1195 | 1195 | client.Kick("Simulator logged you out due to connection timeout"); | |
1196 | if (!client.SceneAgent.IsChildAgent) | 1196 | |
1197 | client.Kick("Simulator logged you out due to connection timeout"); | 1197 | client.CloseWithoutChecks(true); |
1198 | 1198 | } | |
1199 | Util.FireAndForget(o => client.Close()); | ||
1200 | } | 1199 | } |
1201 | 1200 | ||
1202 | private void IncomingPacketHandler() | 1201 | private void IncomingPacketHandler() |