From 68c73951efa56344a6f71f839acfacfdc1a3ed5d Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Tue, 14 Jun 2016 01:21:47 +0200 Subject: [PATCH] Make the LLUDPServerShim inheritable. There is absolutely no reason for this to be sealed! --- .../ClientStack/Linden/UDP/LLUDPServer.cs | 147 +++++++++--------- 1 file changed, 73 insertions(+), 74 deletions(-) diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs index 2dc4e1efcf..781dae88d9 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs @@ -51,33 +51,32 @@ namespace OpenSim.Region.ClientStack.LindenUDP /// A shim around LLUDPServer that implements the IClientNetworkServer interface /// [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "LLUDPServerShim")] - public sealed class LLUDPServerShim : INonSharedRegionModule + public class LLUDPServerShim : INonSharedRegionModule { - private bool m_Enabled = true; - private IConfigSource m_Config; + protected IConfigSource m_Config; LLUDPServer m_udpServer; #region INonSharedRegionModule - public string Name + public virtual string Name { get { return "LLUDPServerShim"; } } - public Type ReplaceableInterface + public virtual Type ReplaceableInterface { get { return null; } } - public void Initialise(IConfigSource source) + public virtual void Initialise(IConfigSource source) { m_Config = source; } - public void Close() + public virtual void Close() { } - public void AddRegion(Scene scene) + public virtual void AddRegion(Scene scene) { uint port = (uint)scene.RegionInfo.InternalEndPoint.Port; @@ -88,23 +87,23 @@ namespace OpenSim.Region.ClientStack.LindenUDP AddScene(scene); } - public void RemoveRegion(Scene scene) + public virtual void RemoveRegion(Scene scene) { Stop(); } - public void RegionLoaded(Scene scene) + public virtual void RegionLoaded(Scene scene) { Start(); } #endregion - public void Initialise(IPAddress listenIP, ref uint port, int proxyPortOffsetParm, bool allow_alternate_port, IConfigSource configSource, AgentCircuitManager circuitManager) + public virtual void Initialise(IPAddress listenIP, ref uint port, int proxyPortOffsetParm, bool allow_alternate_port, IConfigSource configSource, AgentCircuitManager circuitManager) { m_udpServer = new LLUDPServer(listenIP, ref port, proxyPortOffsetParm, allow_alternate_port, configSource, circuitManager); } - public void AddScene(IScene scene) + public virtual void AddScene(IScene scene) { m_udpServer.AddScene(scene); @@ -228,17 +227,17 @@ namespace OpenSim.Region.ClientStack.LindenUDP StatVerbosity.Debug)); } - public bool HandlesRegion(Location x) + public virtual bool HandlesRegion(Location x) { return m_udpServer.HandlesRegion(x); } - public void Start() + public virtual void Start() { m_udpServer.Start(); } - public void Stop() + public virtual void Stop() { m_udpServer.Stop(); } @@ -257,7 +256,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP public const int MTU = 1400; /// Number of forced client logouts due to no receipt of packets before timeout. - public int ClientLogoutsDueToNoReceives { get; private set; } + public int ClientLogoutsDueToNoReceives { get; protected set; } /// /// Default packet debug level given to new clients @@ -284,12 +283,12 @@ namespace OpenSim.Region.ClientStack.LindenUDP /// Handlers for incoming packets //PacketEventDictionary packetEvents = new PacketEventDictionary(); /// Incoming packets that are awaiting handling - //private OpenMetaverse.BlockingQueue packetInbox = new OpenMetaverse.BlockingQueue(); + //protected OpenMetaverse.BlockingQueue packetInbox = new OpenMetaverse.BlockingQueue(); - private OpenSim.Framework.BlockingQueue packetInbox = new OpenSim.Framework.BlockingQueue(); + protected OpenSim.Framework.BlockingQueue packetInbox = new OpenSim.Framework.BlockingQueue(); /// Bandwidth throttle for this UDP server - public TokenBucket Throttle { get; private set; } + public TokenBucket Throttle { get; protected set; } /// Per client throttle rates enforced by this server /// @@ -297,43 +296,43 @@ namespace OpenSim.Region.ClientStack.LindenUDP /// The other rates (resend, asset, etc.) are the defaults for a new client and can be changed (and usually /// do get changed immediately). They do not need to sum to the total. /// - public ThrottleRates ThrottleRates { get; private set; } + public ThrottleRates ThrottleRates { get; protected set; } /// Manages authentication for agent circuits - private AgentCircuitManager m_circuitManager; + protected AgentCircuitManager m_circuitManager; /// Reference to the scene this UDP server is attached to - public Scene Scene { get; private set; } + public Scene Scene { get; protected set; } /// The X/Y coordinates of the scene this UDP server is attached to - private Location m_location; + protected Location m_location; /// The size of the receive buffer for the UDP socket. This value /// is passed up to the operating system and used in the system networking /// stack. Use zero to leave this value as the default - private int m_recvBufferSize; + protected int m_recvBufferSize; /// Flag to process packets asynchronously or synchronously - private bool m_asyncPacketHandling; + protected bool m_asyncPacketHandling; /// Tracks whether or not a packet was sent each round so we know /// whether or not to sleep - private bool m_packetSent; + protected bool m_packetSent; /// Environment.TickCount of the last time that packet stats were reported to the scene - private int m_elapsedMSSinceLastStatReport = 0; + protected int m_elapsedMSSinceLastStatReport = 0; /// Environment.TickCount of the last time the outgoing packet handler executed - private int m_tickLastOutgoingPacketHandler; + protected int m_tickLastOutgoingPacketHandler; /// Keeps track of the number of elapsed milliseconds since the last time the outgoing packet handler looped - private int m_elapsedMSOutgoingPacketHandler; + protected int m_elapsedMSOutgoingPacketHandler; /// Keeps track of the number of 100 millisecond periods elapsed in the outgoing packet handler executed - private int m_elapsed100MSOutgoingPacketHandler; + protected int m_elapsed100MSOutgoingPacketHandler; /// Keeps track of the number of 500 millisecond periods elapsed in the outgoing packet handler executed - private int m_elapsed500MSOutgoingPacketHandler; + protected int m_elapsed500MSOutgoingPacketHandler; /// Flag to signal when clients should check for resends protected bool m_resendUnacked; @@ -344,7 +343,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP /// Flag to signal when clients should send pings protected bool m_sendPing; - private int m_animationSequenceNumber; + protected int m_animationSequenceNumber; public int NextAnimationSequenceNumber { @@ -359,7 +358,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP - private ExpiringCache> m_pendingCache = new ExpiringCache>(); + protected ExpiringCache> m_pendingCache = new ExpiringCache>(); /// /// Event used to signal when queued packets are available for sending. @@ -369,25 +368,25 @@ namespace OpenSim.Region.ClientStack.LindenUDP /// Some data is sent immediately and not queued. That data would not trigger this event. /// WRONG use. May be usefull in future revision /// -// private AutoResetEvent m_dataPresentEvent = new AutoResetEvent(false); +// protected AutoResetEvent m_dataPresentEvent = new AutoResetEvent(false); - private Pool m_incomingPacketPool; + protected Pool m_incomingPacketPool; /// /// Stat for number of packets in the main pool awaiting use. /// - private Stat m_poolCountStat; + protected Stat m_poolCountStat; /// /// Stat for number of packets in the inbound packet pool awaiting use. /// - private Stat m_incomingPacketPoolStat; + protected Stat m_incomingPacketPoolStat; - private int m_defaultRTO = 0; - private int m_maxRTO = 0; - private int m_ackTimeout = 0; - private int m_pausedAckTimeout = 0; - private bool m_disableFacelights = false; + protected int m_defaultRTO = 0; + protected int m_maxRTO = 0; + protected int m_ackTimeout = 0; + protected int m_pausedAckTimeout = 0; + protected bool m_disableFacelights = false; public Socket Server { get { return null; } } @@ -409,28 +408,28 @@ namespace OpenSim.Region.ClientStack.LindenUDP /// /// Record how many inbound packets could not be recognized as LLUDP packets. /// - public int IncomingMalformedPacketCount { get; private set; } + public int IncomingMalformedPacketCount { get; protected set; } /// /// Record how many inbound packets could not be associated with a simulator circuit. /// - public int IncomingOrphanedPacketCount { get; private set; } + public int IncomingOrphanedPacketCount { get; protected set; } /// /// Record current outgoing client for monitoring purposes. /// - private IClientAPI m_currentOutgoingClient; + protected IClientAPI m_currentOutgoingClient; /// /// Recording current incoming client for monitoring purposes. /// - private IClientAPI m_currentIncomingClient; + protected IClientAPI m_currentIncomingClient; /// /// Queue some low priority but potentially high volume async requests so that they don't overwhelm available /// threadpool threads. /// - public JobEngine IpahEngine { get; private set; } + public JobEngine IpahEngine { get; protected set; } /// /// Run queue empty processing within a single persistent thread. @@ -440,7 +439,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP /// connection schedule its own job in the threadpool which causes performance problems when there are many /// connections. /// - public JobEngine OqrEngine { get; private set; } + public JobEngine OqrEngine { get; protected set; } public LLUDPServer( IPAddress listenIP, ref uint port, int proxyPortOffsetParm, bool allow_alternate_port, @@ -662,7 +661,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP /// If the outgoing UDP thread times out, then return client that was being processed to help with debugging. /// /// - private string GetWatchdogIncomingAlarmData() + protected string GetWatchdogIncomingAlarmData() { return string.Format( "Client is {0}", @@ -673,7 +672,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP /// If the outgoing UDP thread times out, then return client that was being processed to help with debugging. /// /// - private string GetWatchdogOutgoingAlarmData() + protected string GetWatchdogOutgoingAlarmData() { return string.Format( "Client is {0}", @@ -1237,7 +1236,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP outgoingPacket.TickCount = Environment.TickCount & Int32.MaxValue; } - private void RecordMalformedInboundPacket(IPEndPoint endPoint) + protected void RecordMalformedInboundPacket(IPEndPoint endPoint) { // if (m_malformedCount < 100) // m_log.DebugFormat("[LLUDPSERVER]: Dropped malformed packet: " + e.ToString()); @@ -1666,7 +1665,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP #endregion BinaryStats - private void HandleUseCircuitCode(object o) + protected void HandleUseCircuitCode(object o) { IPEndPoint endPoint = null; IClientAPI client = null; @@ -1775,7 +1774,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } } /* - private void HandleCompleteMovementIntoRegion(object o) + protected void HandleCompleteMovementIntoRegion(object o) { IPEndPoint endPoint = null; IClientAPI client = null; @@ -1895,7 +1894,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP /// /// /// - private void SendAckImmediate(IPEndPoint remoteEndpoint, uint sequenceNumber) + protected void SendAckImmediate(IPEndPoint remoteEndpoint, uint sequenceNumber) { PacketAckPacket ack = new PacketAckPacket(); ack.Header.Reliable = false; @@ -1919,7 +1918,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP AsyncBeginSend(buffer); } - private bool IsClientAuthorized(UseCircuitCodePacket useCircuitCode, out AuthenticateResponse sessionInfo) + protected bool IsClientAuthorized(UseCircuitCodePacket useCircuitCode, out AuthenticateResponse sessionInfo) { UUID agentID = useCircuitCode.CircuitCode.ID; UUID sessionID = useCircuitCode.CircuitCode.SessionID; @@ -1989,7 +1988,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP /// /// /// - private void DeactivateClientDueToTimeout(LLClientView client, int timeoutTicks) + protected void DeactivateClientDueToTimeout(LLClientView client, int timeoutTicks) { lock (client.CloseSyncLock) { @@ -2010,7 +2009,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP client.Close(true,true); } - private void IncomingPacketHandler() + protected void IncomingPacketHandler() { Thread.CurrentThread.Priority = ThreadPriority.Highest; IncomingPacket incomingPacket; @@ -2052,7 +2051,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP Watchdog.RemoveThread(); } - private void OutgoingPacketHandler() + protected void OutgoingPacketHandler() { Thread.CurrentThread.Priority = ThreadPriority.Highest; @@ -2181,27 +2180,27 @@ namespace OpenSim.Region.ClientStack.LindenUDP #region Emergency Monitoring // Alternative packet handler fuull of instrumentation // Handy for hunting bugs - private Stopwatch watch1 = new Stopwatch(); - private Stopwatch watch2 = new Stopwatch(); + protected Stopwatch watch1 = new Stopwatch(); + protected Stopwatch watch2 = new Stopwatch(); - private float avgProcessingTicks = 0; - private float avgResendUnackedTicks = 0; - private float avgSendAcksTicks = 0; - private float avgSendPingTicks = 0; - private float avgDequeueTicks = 0; - private long nticks = 0; - private long nticksUnack = 0; - private long nticksAck = 0; - private long nticksPing = 0; - private int npacksSent = 0; - private int npackNotSent = 0; + protected float avgProcessingTicks = 0; + protected float avgResendUnackedTicks = 0; + protected float avgSendAcksTicks = 0; + protected float avgSendPingTicks = 0; + protected float avgDequeueTicks = 0; + protected long nticks = 0; + protected long nticksUnack = 0; + protected long nticksAck = 0; + protected long nticksPing = 0; + protected int npacksSent = 0; + protected int npackNotSent = 0; /// /// Number of inbound packets processed since startup. /// - public long IncomingPacketsProcessed { get; private set; } + public long IncomingPacketsProcessed { get; protected set; } - private void MonitoredClientOutgoingPacketHandler(IClientAPI client) + protected void MonitoredClientOutgoingPacketHandler(IClientAPI client) { nticks++; watch1.Start(); @@ -2296,7 +2295,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP #endregion - private void ProcessInPacket(IncomingPacket incomingPacket) + protected void ProcessInPacket(IncomingPacket incomingPacket) { Packet packet = incomingPacket.Packet; LLClientView client = incomingPacket.Client;