* 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
This commit is contained in:
John Hurliman
2007-07-18 04:02:50 +00:00
parent f20dc4cb8f
commit ed1f663217
3 changed files with 35 additions and 35 deletions

View File

@@ -1002,24 +1002,31 @@ namespace libsecondlife
GroupRoleMembersReplyPacket members = (GroupRoleMembersReplyPacket)packet;
List<KeyValuePair<LLUUID, LLUUID>> 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<LLUUID, LLUUID> rolemember =
new KeyValuePair<LLUUID, LLUUID>(block.RoleID, block.MemberID);
groupRoleMemberCache = GroupRolesMembersCaches[members.AgentData.RequestID];
groupRoleMemberCache.Add(rolemember);
foreach (GroupRoleMembersReplyPacket.MemberDataBlock block in members.MemberData)
{
KeyValuePair<LLUUID, LLUUID> rolemember =
new KeyValuePair<LLUUID, LLUUID>(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)

View File

@@ -83,7 +83,7 @@ namespace libsecondlife
public const int MAX_SEQUENCE = 0xFFFFFF;
/// <summary>The maximum size of the sequence number archive, used to
/// check for resent and/or duplicate packets</summary>
public const int PACKET_ARCHIVE_SIZE = 50;
public const int PACKET_ARCHIVE_SIZE = 200;
/// <summary>Number of milliseconds between sending pings to each sim</summary>
public const int PING_INTERVAL = 2200;
/// <summary>Number of milliseconds between sending camera updates</summary>
@@ -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</remarks>
public bool SEND_AGENT_THROTTLE = true;
/// <summary></summary>
public bool OUTBOUND_THROTTLE = false;
/// <summary>Maximum outgoing bytes/sec, per sim</summary>
public int OUTBOUND_THROTTLE_RATE = 1500;
/// <summary>Enable/disable the sending of pings to monitor lag and
/// packet loss</summary>
public bool SEND_PINGS = false;

View File

@@ -557,8 +557,6 @@ namespace libsecondlife
/// should be modified to the current stream sequence number</param>
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);
}
}
/// <summary>
/// Send a prepared <code>UDPPacketBuffer</code> object as a packet
/// </summary>
/// <param name="buffer">The prepared packet structure to be sent out</param>
public void SendPacket(UDPPacketBuffer buffer)
{
try { AsyncBeginSend(buffer); }
catch (Exception e) { Client.Log(e.ToString(), Helpers.LogLevel.Error); }
}
/// <summary>
@@ -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);
}
}
/// <summary>
/// Sends out pending acknowledgements
/// </summary>