diff options
author | Melanie | 2012-07-20 09:31:06 +0100 |
---|---|---|
committer | Melanie | 2012-07-20 09:31:06 +0100 |
commit | 7da744566d491a30c1baf99af39478518d75a6a9 (patch) | |
tree | 3f69ee9d45475fd4e8d09a85b0ab78150f3d9943 /OpenSim/Region/ClientStack/Linden/UDP | |
parent | Merge branch 'master' into careminster (diff) | |
parent | minor: switch around mixed up circuit code and endpoint data in "show connect... (diff) | |
download | opensim-SC_OLD-7da744566d491a30c1baf99af39478518d75a6a9.zip opensim-SC_OLD-7da744566d491a30c1baf99af39478518d75a6a9.tar.gz opensim-SC_OLD-7da744566d491a30c1baf99af39478518d75a6a9.tar.bz2 opensim-SC_OLD-7da744566d491a30c1baf99af39478518d75a6a9.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/ScenePresence.cs
Diffstat (limited to 'OpenSim/Region/ClientStack/Linden/UDP')
-rw-r--r-- | OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs | 59 | ||||
-rw-r--r-- | OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs | 29 |
2 files changed, 58 insertions, 30 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs index e6289bd..4be83f3 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs | |||
@@ -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); |
@@ -3630,7 +3657,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
3630 | 3657 | ||
3631 | public void SendCoarseLocationUpdate(List<UUID> users, List<Vector3> CoarseLocations) | 3658 | public void SendCoarseLocationUpdate(List<UUID> users, List<Vector3> CoarseLocations) |
3632 | { | 3659 | { |
3633 | if (!IsActive) return; // We don't need to update inactive clients. | 3660 | // We don't need to update inactive clients. |
3661 | if (!IsActive) | ||
3662 | return; | ||
3634 | 3663 | ||
3635 | CoarseLocationUpdatePacket loc = (CoarseLocationUpdatePacket)PacketPool.Instance.GetPacket(PacketType.CoarseLocationUpdate); | 3664 | CoarseLocationUpdatePacket loc = (CoarseLocationUpdatePacket)PacketPool.Instance.GetPacket(PacketType.CoarseLocationUpdate); |
3636 | loc.Header.Reliable = false; | 3665 | loc.Header.Reliable = false; |
@@ -5263,7 +5292,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
5263 | AddLocalPacketHandler(PacketType.ChatFromViewer, HandleChatFromViewer); | 5292 | AddLocalPacketHandler(PacketType.ChatFromViewer, HandleChatFromViewer); |
5264 | AddLocalPacketHandler(PacketType.AvatarPropertiesUpdate, HandlerAvatarPropertiesUpdate); | 5293 | AddLocalPacketHandler(PacketType.AvatarPropertiesUpdate, HandlerAvatarPropertiesUpdate); |
5265 | AddLocalPacketHandler(PacketType.ScriptDialogReply, HandlerScriptDialogReply); | 5294 | AddLocalPacketHandler(PacketType.ScriptDialogReply, HandlerScriptDialogReply); |
5266 | AddLocalPacketHandler(PacketType.ImprovedInstantMessage, HandlerImprovedInstantMessage, false); | 5295 | AddLocalPacketHandler(PacketType.ImprovedInstantMessage, HandlerImprovedInstantMessage); |
5267 | AddLocalPacketHandler(PacketType.AcceptFriendship, HandlerAcceptFriendship); | 5296 | AddLocalPacketHandler(PacketType.AcceptFriendship, HandlerAcceptFriendship); |
5268 | AddLocalPacketHandler(PacketType.DeclineFriendship, HandlerDeclineFriendship); | 5297 | AddLocalPacketHandler(PacketType.DeclineFriendship, HandlerDeclineFriendship); |
5269 | AddLocalPacketHandler(PacketType.TerminateFriendship, HandlerTerminateFriendship); | 5298 | AddLocalPacketHandler(PacketType.TerminateFriendship, HandlerTerminateFriendship); |
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs index 79e35f4..140a953 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs | |||
@@ -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() |