- Lower TIME_MS_TOLERANCE to 200ms - Allow m_updateFlag to be reset to 0 in the event of a terse update being rejected - Re-add a synchronous SendTo for certain types of packets

avinationmerge
unknown 2009-11-15 21:38:38 +01:00 committed by Melanie
parent d5c18f6149
commit 28aa8010b2
4 changed files with 49 additions and 15 deletions

View File

@ -399,6 +399,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
#region Queue or Send #region Queue or Send
OutgoingPacket outgoingPacket = new OutgoingPacket(udpClient, buffer, category); OutgoingPacket outgoingPacket = new OutgoingPacket(udpClient, buffer, category);
outgoingPacket.Type = type;
if (!outgoingPacket.Client.EnqueueOutgoing(outgoingPacket)) if (!outgoingPacket.Client.EnqueueOutgoing(outgoingPacket))
SendPacketFinal(outgoingPacket); SendPacketFinal(outgoingPacket);
@ -510,6 +511,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
byte flags = buffer.Data[0]; byte flags = buffer.Data[0];
bool isResend = (flags & Helpers.MSG_RESENT) != 0; bool isResend = (flags & Helpers.MSG_RESENT) != 0;
bool isReliable = (flags & Helpers.MSG_RELIABLE) != 0; bool isReliable = (flags & Helpers.MSG_RELIABLE) != 0;
bool sendSynchronous = false;
LLUDPClient udpClient = outgoingPacket.Client; LLUDPClient udpClient = outgoingPacket.Client;
if (!udpClient.IsConnected) if (!udpClient.IsConnected)
@ -565,9 +567,27 @@ namespace OpenSim.Region.ClientStack.LindenUDP
if (isReliable) if (isReliable)
Interlocked.Add(ref udpClient.UnackedBytes, outgoingPacket.Buffer.DataLength); Interlocked.Add(ref udpClient.UnackedBytes, outgoingPacket.Buffer.DataLength);
// Put the UDP payload on the wire //Some packet types need to be sent synchonously.
AsyncBeginSend(buffer); //Sorry, i know it's not optimal, but until the LL client
//manages packets correctly and re-orders them as required, this is necessary.
if (outgoingPacket.Type == PacketType.ImprovedTerseObjectUpdate
|| outgoingPacket.Type == PacketType.ChatFromSimulator
|| outgoingPacket.Type == PacketType.ObjectUpdate
|| outgoingPacket.Type == PacketType.LayerData)
{
sendSynchronous = true;
}
// Put the UDP payload on the wire
if (sendSynchronous == true)
{
SyncBeginSend(buffer);
}
else
{
AsyncBeginSend(buffer);
}
// Keep track of when this packet was sent out (right now) // Keep track of when this packet was sent out (right now)
outgoingPacket.TickCount = Environment.TickCount & Int32.MaxValue; outgoingPacket.TickCount = Environment.TickCount & Int32.MaxValue;
} }

View File

@ -246,6 +246,24 @@ namespace OpenMetaverse
} }
} }
public void SyncBeginSend(UDPPacketBuffer buf)
{
if (!m_shutdownFlag)
{
try
{
m_udpSocket.SendTo(
buf.Data,
0,
buf.DataLength,
SocketFlags.None,
buf.RemoteEndPoint);
}
catch (SocketException) { }
catch (ObjectDisposedException) { }
}
}
public void AsyncBeginSend(UDPPacketBuffer buf) public void AsyncBeginSend(UDPPacketBuffer buf)
{ {
if (!m_shutdownFlag) if (!m_shutdownFlag)

View File

@ -28,6 +28,7 @@
using System; using System;
using OpenSim.Framework; using OpenSim.Framework;
using OpenMetaverse; using OpenMetaverse;
using OpenMetaverse.Packets;
namespace OpenSim.Region.ClientStack.LindenUDP namespace OpenSim.Region.ClientStack.LindenUDP
{ {
@ -52,7 +53,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
public int TickCount; public int TickCount;
/// <summary>Category this packet belongs to</summary> /// <summary>Category this packet belongs to</summary>
public ThrottleOutPacketType Category; public ThrottleOutPacketType Category;
/// <summary>The type of packet so its delivery method can be determined</summary>
public PacketType Type;
/// <summary> /// <summary>
/// Default constructor /// Default constructor
/// </summary> /// </summary>

View File

@ -1064,14 +1064,6 @@ namespace OpenSim.Region.Framework.Scenes
} }
} }
/// <summary>
/// Clear all pending updates of parts to clients
/// </summary>
private void ClearUpdateSchedule()
{
m_updateFlag = 0;
}
private void SendObjectPropertiesToClient(UUID AgentID) private void SendObjectPropertiesToClient(UUID AgentID)
{ {
ScenePresence[] avatars = m_parentGroup.Scene.GetScenePresences(); ScenePresence[] avatars = m_parentGroup.Scene.GetScenePresences();
@ -2387,8 +2379,8 @@ namespace OpenSim.Region.Framework.Scenes
{ {
const float ROTATION_TOLERANCE = 0.01f; const float ROTATION_TOLERANCE = 0.01f;
const float VELOCITY_TOLERANCE = 0.001f; const float VELOCITY_TOLERANCE = 0.001f;
const float POSITION_TOLERANCE = 0.05f; const float POSITION_TOLERANCE = 0.05f; // I don't like this, but I suppose it's necessary
const int TIME_MS_TOLERANCE = 3000; const int TIME_MS_TOLERANCE = 200; //llSetPos has a 200ms delay. This should NOT be 3 seconds.
if (m_updateFlag == 1) if (m_updateFlag == 1)
{ {
@ -2401,7 +2393,7 @@ namespace OpenSim.Region.Framework.Scenes
Environment.TickCount - m_lastTerseSent > TIME_MS_TOLERANCE) Environment.TickCount - m_lastTerseSent > TIME_MS_TOLERANCE)
{ {
AddTerseUpdateToAllAvatars(); AddTerseUpdateToAllAvatars();
ClearUpdateSchedule();
// This causes the Scene to 'poll' physical objects every couple of frames // This causes the Scene to 'poll' physical objects every couple of frames
// bad, so it's been replaced by an event driven method. // bad, so it's been replaced by an event driven method.
@ -2419,13 +2411,15 @@ namespace OpenSim.Region.Framework.Scenes
m_lastAngularVelocity = AngularVelocity; m_lastAngularVelocity = AngularVelocity;
m_lastTerseSent = Environment.TickCount; m_lastTerseSent = Environment.TickCount;
} }
//Moved this outside of the if clause so updates don't get blocked.. *sigh*
m_updateFlag = 0; //Why were we calling a function to do this? Inefficient! *screams*
} }
else else
{ {
if (m_updateFlag == 2) // is a new prim, just created/reloaded or has major changes if (m_updateFlag == 2) // is a new prim, just created/reloaded or has major changes
{ {
AddFullUpdateToAllAvatars(); AddFullUpdateToAllAvatars();
ClearUpdateSchedule(); m_updateFlag = 0; //Same here
} }
} }
} }