From 3564271c2d4f769361e36e2a10acbeb3e5f56bdf Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Wed, 1 Jul 2009 15:47:52 +0000 Subject: Restore the functionality that was removed in r9928. This lets the load balancer plugin work again. Create a new method, GetClientEP, to retrieve only the EndPoint for script usage. Marked the purpose of the method in IClientAPI.cs with a warning. Also restored the corresponding SetClientInfo functionality. --- OpenSim/Client/MXP/ClientStack/MXPClientView.cs | 5 ++ .../Client/VWoHTTP/ClientStack/VWHClientView.cs | 5 ++ OpenSim/Framework/IClientAPI.cs | 9 +- .../Region/ClientStack/LindenUDP/LLClientView.cs | 5 ++ .../ClientStack/LindenUDP/LLPacketHandler.cs | 95 ++++++++++------------ .../Region/Examples/SimpleModule/MyNpcCharacter.cs | 5 ++ .../Server/IRCClientView.cs | 5 ++ .../Region/OptionalModules/World/NPC/NPCAvatar.cs | 5 ++ .../Shared/Api/Implementation/OSSL_Api.cs | 2 +- OpenSim/Tests/Common/Mock/TestClient.cs | 5 ++ 10 files changed, 89 insertions(+), 52 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Client/MXP/ClientStack/MXPClientView.cs b/OpenSim/Client/MXP/ClientStack/MXPClientView.cs index 660bb3e..df1b4a3 100644 --- a/OpenSim/Client/MXP/ClientStack/MXPClientView.cs +++ b/OpenSim/Client/MXP/ClientStack/MXPClientView.cs @@ -1417,6 +1417,11 @@ namespace OpenSim.Client.MXP.ClientStack Session.Send(lrm); } + public EndPoint GetClientEP() + { + return null; + } + public ClientInfo GetClientInfo() { return null; diff --git a/OpenSim/Client/VWoHTTP/ClientStack/VWHClientView.cs b/OpenSim/Client/VWoHTTP/ClientStack/VWHClientView.cs index 225ef69..c0c7625 100644 --- a/OpenSim/Client/VWoHTTP/ClientStack/VWHClientView.cs +++ b/OpenSim/Client/VWoHTTP/ClientStack/VWHClientView.cs @@ -942,6 +942,11 @@ namespace OpenSim.Client.VWoHTTP.ClientStack throw new System.NotImplementedException(); } + public EndPoint GetClientEP() + { + return null; + } + public ClientInfo GetClientInfo() { throw new System.NotImplementedException(); diff --git a/OpenSim/Framework/IClientAPI.cs b/OpenSim/Framework/IClientAPI.cs index 2a81d5c..7c8b1aa 100644 --- a/OpenSim/Framework/IClientAPI.cs +++ b/OpenSim/Framework/IClientAPI.cs @@ -1108,9 +1108,16 @@ namespace OpenSim.Framework void SendBlueBoxMessage(UUID FromAvatarID, String FromAvatarName, String Message); void SendLogoutPacket(); - ClientInfo GetClientInfo(); + EndPoint GetClientEP(); + // WARNING WARNING WARNING + // + // The two following methods are EXCLUSIVELY for the load balancer. + // they cause a MASSIVE performance hit! + // + ClientInfo GetClientInfo(); void SetClientInfo(ClientInfo info); + void SetClientOption(string option, string value); string GetClientOption(string option); void Terminate(); diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index 3813367..74a8874 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs @@ -9919,6 +9919,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP return info; } + public EndPoint GetClientEP() + { + return m_userEndPoint; + } + public void SetClientInfo(ClientInfo info) { m_PacketHandler.SetClientInfo(info); diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLPacketHandler.cs b/OpenSim/Region/ClientStack/LindenUDP/LLPacketHandler.cs index c0fb1c7..4b1a6b7 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLPacketHandler.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLPacketHandler.cs @@ -643,28 +643,22 @@ namespace OpenSim.Region.ClientStack.LindenUDP { ClientInfo info = new ClientInfo(); - // nobody seems to even look at the following data. since - // it's a rather expensive operation (lock, serializing - // packets, copying it into dictionary, etc) i've - // commented out the expensive (but unwanted?) bits below - // (dr scofield, 2009-06-24) + info.pendingAcks = m_PendingAcksMap; + info.needAck = new Dictionary(); - // info.pendingAcks = m_PendingAcks; - // info.needAck = new Dictionary(); - - // lock (m_NeedAck) - // { - // foreach (uint key in m_NeedAck.Keys) - // info.needAck.Add(key, m_NeedAck[key].Packet.ToBytes()); - // } + lock (m_NeedAck) + { + foreach (uint key in m_NeedAck.Keys) + info.needAck.Add(key, m_NeedAck[key].Packet.ToBytes()); + } - // LLQueItem[] queitems = m_PacketQueue.GetQueueArray(); + LLQueItem[] queitems = m_PacketQueue.GetQueueArray(); - // for (int i = 0; i < queitems.Length; i++) - // { - // if (queitems[i].Incoming == false) - // info.out_packets.Add(queitems[i].Packet.ToBytes()); - // } + for (int i = 0; i < queitems.Length; i++) + { + if (queitems[i].Incoming == false) + info.out_packets.Add(queitems[i].Packet.ToBytes()); + } info.sequence = m_Sequence; @@ -683,37 +677,38 @@ namespace OpenSim.Region.ClientStack.LindenUDP public void SetClientInfo(ClientInfo info) { - // m_PendingAcks = info.pendingAcks; - // m_NeedAck = new Dictionary(); - - // Packet packet = null; - // int packetEnd = 0; - // byte[] zero = new byte[3000]; - - // foreach (uint key in info.needAck.Keys) - // { - // byte[] buff = info.needAck[key]; - // packetEnd = buff.Length - 1; - - // try - // { - // packet = PacketPool.Instance.GetPacket(buff, ref packetEnd, zero); - // } - // catch (Exception) - // { - // } - - // LLQueItem item = new LLQueItem(); - // item.Packet = packet; - // item.Incoming = false; - // item.throttleType = 0; - // item.TickCount = Environment.TickCount; - // item.Identifier = 0; - // item.Resends = 0; - // item.Length = packet.Length; - // item.Sequence = packet.Header.Sequence; - // m_NeedAck.Add(key, item); - // } + m_PendingAcksMap = info.pendingAcks; + m_PendingAcks = new List(m_PendingAcksMap.Keys); + m_NeedAck = new Dictionary(); + + Packet packet = null; + int packetEnd = 0; + byte[] zero = new byte[3000]; + + foreach (uint key in info.needAck.Keys) + { + byte[] buff = info.needAck[key]; + packetEnd = buff.Length - 1; + + try + { + packet = PacketPool.Instance.GetPacket(buff, ref packetEnd, zero); + } + catch (Exception) + { + } + + LLQueItem item = new LLQueItem(); + item.Packet = packet; + item.Incoming = false; + item.throttleType = 0; + item.TickCount = Environment.TickCount; + item.Identifier = 0; + item.Resends = 0; + item.Length = packet.Length; + item.Sequence = packet.Header.Sequence; + m_NeedAck.Add(key, item); + } m_Sequence = info.sequence; diff --git a/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs b/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs index f797dbc..5e33729 100644 --- a/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs +++ b/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs @@ -843,6 +843,11 @@ namespace OpenSim.Region.Examples.SimpleModule { } + public EndPoint GetClientEP() + { + return null; + } + public ClientInfo GetClientInfo() { return null; diff --git a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs index 9002a21..8ec1780 100644 --- a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs +++ b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs @@ -1396,6 +1396,11 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server Disconnect(); } + public EndPoint GetClientEP() + { + return null; + } + public ClientInfo GetClientInfo() { return new ClientInfo(); diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs index 0505fe8..228683e 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs @@ -855,6 +855,11 @@ namespace OpenSim.Region.OptionalModules.World.NPC { } + public EndPoint GetClientEP() + { + return null; + } + public ClientInfo GetClientInfo() { return null; diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 73c3e4c..7c878b8 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -666,7 +666,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (World.Entities.ContainsKey((UUID)agent) && World.Entities[avatarID] is ScenePresence) { ScenePresence target = (ScenePresence)World.Entities[avatarID]; - EndPoint ep = target.ControllingClient.GetClientInfo().userEP; + EndPoint ep = target.ControllingClient.GetClientEP(); if (ep is IPEndPoint) { IPEndPoint ip = (IPEndPoint)ep; diff --git a/OpenSim/Tests/Common/Mock/TestClient.cs b/OpenSim/Tests/Common/Mock/TestClient.cs index 64af13d..c76d180 100644 --- a/OpenSim/Tests/Common/Mock/TestClient.cs +++ b/OpenSim/Tests/Common/Mock/TestClient.cs @@ -888,6 +888,11 @@ namespace OpenSim.Tests.Common.Mock { } + public EndPoint GetClientEP() + { + return null; + } + public ClientInfo GetClientInfo() { return null; -- cgit v1.1