From ed1f66321753669dbae5eb7c4ef80c0bd035e73e Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Wed, 18 Jul 2007 04:02:50 +0000 Subject: [PATCH] * Adding a try/catch to GroupRoleMembersHandler as a hacky workaround to some NullReferenceExceptions I've had there * Removing any of the (now irrelevant) outbound throttling code * Adding another SendPacket() overload git-svn-id: http://libopenmetaverse.googlecode.com/svn/trunk@1318 52acb1d6-8a22-11de-b505-999d5b087335 --- libsecondlife/GroupManager.cs | 27 +++++++++++++++---------- libsecondlife/Settings.cs | 6 +----- libsecondlife/Simulator.cs | 37 ++++++++++++++++------------------- 3 files changed, 35 insertions(+), 35 deletions(-) diff --git a/libsecondlife/GroupManager.cs b/libsecondlife/GroupManager.cs index 9d7a1352..37afd528 100644 --- a/libsecondlife/GroupManager.cs +++ b/libsecondlife/GroupManager.cs @@ -1002,24 +1002,31 @@ namespace libsecondlife GroupRoleMembersReplyPacket members = (GroupRoleMembersReplyPacket)packet; List> groupRoleMemberCache = null; - lock (GroupRolesMembersCaches) + try { - // If nothing is registered to receive this RequestID drop the data - if (GroupRolesMembersCaches.ContainsKey(members.AgentData.RequestID)) + lock (GroupRolesMembersCaches) { - groupRoleMemberCache = GroupRolesMembersCaches[members.AgentData.RequestID]; - - foreach (GroupRoleMembersReplyPacket.MemberDataBlock block in members.MemberData) + // If nothing is registered to receive this RequestID drop the data + if (GroupRolesMembersCaches.ContainsKey(members.AgentData.RequestID)) { - KeyValuePair rolemember = - new KeyValuePair(block.RoleID, block.MemberID); + groupRoleMemberCache = GroupRolesMembersCaches[members.AgentData.RequestID]; - groupRoleMemberCache.Add(rolemember); + foreach (GroupRoleMembersReplyPacket.MemberDataBlock block in members.MemberData) + { + KeyValuePair rolemember = + new KeyValuePair(block.RoleID, block.MemberID); + + groupRoleMemberCache.Add(rolemember); + } } } } + catch (Exception e) + { + Client.Log(e.ToString(), Helpers.LogLevel.Error); + } - Client.DebugLog("Pairs Ratio: " + groupRoleMemberCache.Count + "/" + members.AgentData.TotalPairs); + //Client.DebugLog("Pairs Ratio: " + groupRoleMemberCache.Count + "/" + members.AgentData.TotalPairs); // Check if we've received all the pairs that are showing up if (OnGroupRolesMembers != null && groupRoleMemberCache != null && groupRoleMemberCache.Count >= members.AgentData.TotalPairs) diff --git a/libsecondlife/Settings.cs b/libsecondlife/Settings.cs index a2116414..1e127a2b 100644 --- a/libsecondlife/Settings.cs +++ b/libsecondlife/Settings.cs @@ -83,7 +83,7 @@ namespace libsecondlife public const int MAX_SEQUENCE = 0xFFFFFF; /// The maximum size of the sequence number archive, used to /// check for resent and/or duplicate packets - public const int PACKET_ARCHIVE_SIZE = 50; + public const int PACKET_ARCHIVE_SIZE = 200; /// Number of milliseconds between sending pings to each sim public const int PING_INTERVAL = 2200; /// Number of milliseconds between sending camera updates @@ -128,10 +128,6 @@ namespace libsecondlife /// set a throttle your connection will by default be throttled well /// below the minimum values and you may experience connection problems public bool SEND_AGENT_THROTTLE = true; - /// - public bool OUTBOUND_THROTTLE = false; - /// Maximum outgoing bytes/sec, per sim - public int OUTBOUND_THROTTLE_RATE = 1500; /// Enable/disable the sending of pings to monitor lag and /// packet loss public bool SEND_PINGS = false; diff --git a/libsecondlife/Simulator.cs b/libsecondlife/Simulator.cs index f55dca6f..8b30ce79 100644 --- a/libsecondlife/Simulator.cs +++ b/libsecondlife/Simulator.cs @@ -557,8 +557,6 @@ namespace libsecondlife /// should be modified to the current stream sequence number public void SendPacket(byte[] payload, bool setSequence) { - if (Client.Settings.OUTBOUND_THROTTLE) DoThrottle(); - try { if (setSequence && payload.Length > 3) @@ -583,12 +581,27 @@ namespace libsecondlife } catch (SocketException) { - Client.Log("Tried to send a " + payload.Length + " byte payload on a closed socket, shutting down " + - this.ToString(), Helpers.LogLevel.Info); + Client.Log("Tried to send a " + payload.Length + + " byte payload on a closed socket, shutting down " + this.ToString(), + Helpers.LogLevel.Info); Network.DisconnectSim(this); return; } + catch (Exception e) + { + Client.Log(e.ToString(), Helpers.LogLevel.Error); + } + } + + /// + /// Send a prepared UDPPacketBuffer object as a packet + /// + /// The prepared packet structure to be sent out + public void SendPacket(UDPPacketBuffer buffer) + { + try { AsyncBeginSend(buffer); } + catch (Exception e) { Client.Log(e.ToString(), Helpers.LogLevel.Error); } } /// @@ -720,22 +733,6 @@ namespace libsecondlife { } - private void DoThrottle() - { - int throttle; - - if (OutgoingBPS > Client.Settings.OUTBOUND_THROTTLE_RATE) - { - throttle = (int)((OutgoingBPS - Client.Settings.OUTBOUND_THROTTLE_RATE) * 2000 / - Client.Settings.OUTBOUND_THROTTLE_RATE); - - Client.DebugLog(String.Format("Simulator {0} throttling for {1}ms", this.ToString(), throttle)); - // FIXME: When the outgoing message pumps are in place we won't need to throttle by locking up - // the application - Thread.Sleep(throttle); - } - } - /// /// Sends out pending acknowledgements ///