mirror of
https://github.com/opensim/opensim.git
synced 2026-08-05 00:46:02 +08:00
Merge branch 'master' into httptests
This commit is contained in:
@@ -120,14 +120,13 @@ namespace OpenSim.Region.ClientStack.Linden
|
||||
|
||||
public virtual void RegisterCaps(UUID agentID, Caps caps)
|
||||
{
|
||||
UUID capID = UUID.Random();
|
||||
|
||||
if (m_URL == "localhost")
|
||||
{
|
||||
m_log.DebugFormat("[GET_DISPLAY_NAMES]: /CAPS/agents/{0} in region {1}", capID, m_scene.RegionInfo.RegionName);
|
||||
string capUrl = "/CAPS/" + UUID.Random() + "/";
|
||||
// m_log.DebugFormat("[GET_DISPLAY_NAMES]: {0} in region {1}", capUrl, m_scene.RegionInfo.RegionName);
|
||||
caps.RegisterHandler(
|
||||
"GetDisplayNames",
|
||||
new GetDisplayNamesHandler("/CAPS/agents" + capID + "/", m_UserManager, "GetDisplayNames", agentID.ToString()));
|
||||
new GetDisplayNamesHandler(capUrl, m_UserManager, "GetDisplayNames", agentID.ToString()));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -2856,6 +2856,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||
|
||||
public void SendSelectedPartsProprieties(List<ISceneEntity> parts)
|
||||
{
|
||||
/* not in use
|
||||
// udp part
|
||||
ObjectPropertiesPacket packet =
|
||||
(ObjectPropertiesPacket)PacketPool.Instance.GetPacket(PacketType.ObjectProperties);
|
||||
@@ -2893,6 +2894,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||
llsdBody.Add("ObjectData", array);
|
||||
|
||||
eq.Enqueue(BuildEvent("ObjectPhysicsProperties", llsdBody),AgentId);
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
@@ -4839,7 +4841,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||
|
||||
OpenSim.Framework.Lazy<List<ObjectPropertyUpdate>> propertyUpdates =
|
||||
new OpenSim.Framework.Lazy<List<ObjectPropertyUpdate>>();
|
||||
|
||||
|
||||
List<SceneObjectPart> needPhysics = new List<SceneObjectPart>();
|
||||
|
||||
EntityUpdate iupdate;
|
||||
Int32 timeinqueue; // this is just debugging code & can be dropped later
|
||||
|
||||
@@ -4867,6 +4871,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||
if (update.Entity is SceneObjectPart)
|
||||
{
|
||||
SceneObjectPart sop = (SceneObjectPart)update.Entity;
|
||||
needPhysics.Add(sop);
|
||||
ObjectPropertiesPacket.ObjectDataBlock objPropDB = CreateObjectPropertiesBlock(sop);
|
||||
objectPropertiesBlocks.Value.Add(objPropDB);
|
||||
propertyUpdates.Value.Add(update);
|
||||
@@ -4932,7 +4937,31 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||
// fpcnt++;
|
||||
// fbcnt++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(needPhysics.Count > 0)
|
||||
{
|
||||
IEventQueue eq = Scene.RequestModuleInterface<IEventQueue>();
|
||||
if(eq != null)
|
||||
{
|
||||
OSDArray array = new OSDArray();
|
||||
foreach(SceneObjectPart sop in needPhysics)
|
||||
{
|
||||
OSDMap physinfo = new OSDMap(6);
|
||||
physinfo["LocalID"] = sop.LocalId;
|
||||
physinfo["Density"] = sop.Density;
|
||||
physinfo["Friction"] = sop.Friction;
|
||||
physinfo["GravityMultiplier"] = sop.GravityModifier;
|
||||
physinfo["Restitution"] = sop.Restitution;
|
||||
physinfo["PhysicsShapeType"] = (int)sop.PhysicsShapeType;
|
||||
array.Add(physinfo);
|
||||
}
|
||||
|
||||
OSDMap llsdBody = new OSDMap(1);
|
||||
llsdBody.Add("ObjectData", array);
|
||||
|
||||
eq.Enqueue(BuildEvent("ObjectPhysicsProperties", llsdBody),AgentId);
|
||||
}
|
||||
}
|
||||
|
||||
// m_log.WarnFormat("[PACKETCOUNTS] queued {0} property packets with {1} blocks",ppcnt,pbcnt);
|
||||
@@ -6234,7 +6263,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||
|
||||
bool movement = CheckAgentMovementUpdateSignificance(x);
|
||||
bool camera = CheckAgentCameraUpdateSignificance(x);
|
||||
|
||||
|
||||
// Was there a significant movement/state change?
|
||||
if (movement)
|
||||
{
|
||||
@@ -6245,6 +6274,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||
m_thisAgentUpdateArgs.HeadRotation = x.HeadRotation;
|
||||
m_thisAgentUpdateArgs.State = x.State;
|
||||
|
||||
m_thisAgentUpdateArgs.NeedsCameraCollision = !camera;
|
||||
|
||||
UpdateAgent handlerAgentUpdate = OnAgentUpdate;
|
||||
UpdateAgent handlerPreAgentUpdate = OnPreAgentUpdate;
|
||||
|
||||
@@ -6253,7 +6284,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||
|
||||
if (handlerAgentUpdate != null)
|
||||
OnAgentUpdate(this, m_thisAgentUpdateArgs);
|
||||
|
||||
|
||||
}
|
||||
|
||||
// Was there a significant camera(s) change?
|
||||
@@ -6264,6 +6295,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||
m_thisAgentUpdateArgs.CameraLeftAxis = x.CameraLeftAxis;
|
||||
m_thisAgentUpdateArgs.CameraUpAxis = x.CameraUpAxis;
|
||||
|
||||
m_thisAgentUpdateArgs.NeedsCameraCollision = true;
|
||||
|
||||
UpdateAgent handlerAgentCameraUpdate = OnAgentCameraUpdate;
|
||||
|
||||
if (handlerAgentCameraUpdate != null)
|
||||
|
||||
@@ -161,6 +161,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||
/// <summary>Total byte count of unacked packets sent to this client</summary>
|
||||
public int UnackedBytes;
|
||||
|
||||
private int m_packetsUnAckReported;
|
||||
/// <summary>Total number of received packets that we have reported to the OnPacketStats event(s)</summary>
|
||||
private int m_packetsReceivedReported;
|
||||
/// <summary>Total number of sent packets that we have reported to the OnPacketStats event(s)</summary>
|
||||
@@ -389,11 +390,12 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||
{
|
||||
int newPacketsReceived = PacketsReceived - m_packetsReceivedReported;
|
||||
int newPacketsSent = PacketsSent - m_packetsSentReported;
|
||||
|
||||
int newPacketUnAck = UnackedBytes - m_packetsUnAckReported;
|
||||
callback(newPacketsReceived, newPacketsSent, UnackedBytes);
|
||||
|
||||
m_packetsReceivedReported += newPacketsReceived;
|
||||
m_packetsSentReported += newPacketsSent;
|
||||
m_packetsUnAckReported += newPacketUnAck;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -323,7 +323,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||
protected int m_elapsedMSSinceLastStatReport = 0;
|
||||
|
||||
/// <summary>Environment.TickCount of the last time the outgoing packet handler executed</summary>
|
||||
protected int m_tickLastOutgoingPacketHandler;
|
||||
protected double m_tickLastOutgoingPacketHandler;
|
||||
|
||||
/// <summary>Keeps track of the number of elapsed milliseconds since the last time the outgoing packet handler looped</summary>
|
||||
protected int m_elapsedMSOutgoingPacketHandler;
|
||||
@@ -356,20 +356,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected ExpiringCache<IPEndPoint, Queue<UDPPacketBuffer>> m_pendingCache = new ExpiringCache<IPEndPoint, Queue<UDPPacketBuffer>>();
|
||||
|
||||
/// <summary>
|
||||
/// Event used to signal when queued packets are available for sending.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This allows the outbound loop to only operate when there is data to send rather than continuously polling.
|
||||
/// Some data is sent immediately and not queued. That data would not trigger this event.
|
||||
/// WRONG use. May be usefull in future revision
|
||||
/// </remarks>
|
||||
// protected AutoResetEvent m_dataPresentEvent = new AutoResetEvent(false);
|
||||
|
||||
protected Pool<IncomingPacket> m_incomingPacketPool;
|
||||
|
||||
/// <summary>
|
||||
@@ -456,10 +444,22 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||
int now = start;
|
||||
while (now == start)
|
||||
now = Environment.TickCount;
|
||||
TickCountResolution += (float)(now - start) * 0.1f;
|
||||
TickCountResolution += (float)(now - start);
|
||||
}
|
||||
TickCountResolution = (float)Math.Ceiling(TickCountResolution);
|
||||
m_log.Info("[LLUDPSERVER]: Average Environment.TickCount resolution: " + TickCountResolution + "ms");
|
||||
m_log.Info("[LLUDPSERVER]: Average Environment.TickCount resolution: " + TickCountResolution * 0.1f + "ms");
|
||||
|
||||
TickCountResolution = 0f;
|
||||
for (int i = 0; i < 100; i++)
|
||||
{
|
||||
double start = Util.GetTimeStampMS();
|
||||
double now = start;
|
||||
while (now == start)
|
||||
now = Util.GetTimeStampMS();
|
||||
TickCountResolution += (float)((now - start));
|
||||
}
|
||||
|
||||
TickCountResolution = (float)Math.Round(TickCountResolution * 0.01f,6,MidpointRounding.AwayFromZero);
|
||||
m_log.Info("[LLUDPSERVER]: Average Util.GetTimeStampMS resolution: " + TickCountResolution + "ms");
|
||||
|
||||
#endregion Environment.TickCount Measurement
|
||||
|
||||
@@ -467,8 +467,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||
int sceneThrottleBps = 0;
|
||||
bool usePools = false;
|
||||
|
||||
|
||||
|
||||
IConfig config = configSource.Configs["ClientStack.LindenUDP"];
|
||||
if (config != null)
|
||||
{
|
||||
@@ -927,10 +925,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||
}
|
||||
|
||||
PacketPool.Instance.ReturnPacket(packet);
|
||||
|
||||
/// WRONG use. May be usefull in future revision
|
||||
// if (packetQueued)
|
||||
// m_dataPresentEvent.Set();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -2079,14 +2073,14 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||
m_sendPing = false;
|
||||
|
||||
// Update elapsed time
|
||||
int thisTick = Environment.TickCount & Int32.MaxValue;
|
||||
if (m_tickLastOutgoingPacketHandler > thisTick)
|
||||
m_elapsedMSOutgoingPacketHandler += ((Int32.MaxValue - m_tickLastOutgoingPacketHandler) + thisTick);
|
||||
else
|
||||
m_elapsedMSOutgoingPacketHandler += (thisTick - m_tickLastOutgoingPacketHandler);
|
||||
|
||||
double thisTick = Util.GetTimeStampMS();
|
||||
int deltaMS = (int)(thisTick - m_tickLastOutgoingPacketHandler);
|
||||
m_tickLastOutgoingPacketHandler = thisTick;
|
||||
|
||||
// update some 1ms resolution chained timers
|
||||
|
||||
m_elapsedMSOutgoingPacketHandler += deltaMS;
|
||||
|
||||
// Check for pending outgoing resends every 100ms
|
||||
if (m_elapsedMSOutgoingPacketHandler >= 100)
|
||||
{
|
||||
@@ -2109,15 +2103,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||
m_sendPing = true;
|
||||
m_elapsed500MSOutgoingPacketHandler = 0;
|
||||
}
|
||||
|
||||
#endregion Update Timers
|
||||
|
||||
// Use this for emergency monitoring -- bug hunting
|
||||
//if (m_scene.EmergencyMonitoring)
|
||||
// clientPacketHandler = MonitoredClientOutgoingPacketHandler;
|
||||
//else
|
||||
// clientPacketHandler = ClientOutgoingPacketHandler;
|
||||
|
||||
// Handle outgoing packets, resends, acknowledgements, and pings for each
|
||||
// client. m_packetSent will be set to true if a packet is sent
|
||||
Scene.ForEachClient(clientPacketHandler);
|
||||
@@ -2129,7 +2116,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||
|
||||
if(Scene.GetNumberOfClients() == 0)
|
||||
{
|
||||
Thread.Sleep(250); // be friendly to PIs, but how long ??
|
||||
Thread.Sleep(100);
|
||||
}
|
||||
else if (!m_packetSent)
|
||||
// Thread.Sleep((int)TickCountResolution); outch this is bad on linux
|
||||
@@ -2204,99 +2191,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||
/// </summary>
|
||||
public long IncomingPacketsProcessed { get; protected set; }
|
||||
|
||||
protected void MonitoredClientOutgoingPacketHandler(IClientAPI client)
|
||||
{
|
||||
nticks++;
|
||||
watch1.Start();
|
||||
m_currentOutgoingClient = client;
|
||||
|
||||
try
|
||||
{
|
||||
if (client is LLClientView)
|
||||
{
|
||||
LLClientView llClient = (LLClientView)client;
|
||||
LLUDPClient udpClient = llClient.UDPClient;
|
||||
|
||||
if (udpClient.IsConnected)
|
||||
{
|
||||
if (m_resendUnacked)
|
||||
{
|
||||
nticksUnack++;
|
||||
watch2.Start();
|
||||
|
||||
HandleUnacked(llClient);
|
||||
|
||||
watch2.Stop();
|
||||
avgResendUnackedTicks = (nticksUnack - 1)/(float)nticksUnack * avgResendUnackedTicks + (watch2.ElapsedTicks / (float)nticksUnack);
|
||||
watch2.Reset();
|
||||
}
|
||||
|
||||
if (m_sendAcks)
|
||||
{
|
||||
nticksAck++;
|
||||
watch2.Start();
|
||||
|
||||
SendAcks(udpClient);
|
||||
|
||||
watch2.Stop();
|
||||
avgSendAcksTicks = (nticksAck - 1) / (float)nticksAck * avgSendAcksTicks + (watch2.ElapsedTicks / (float)nticksAck);
|
||||
watch2.Reset();
|
||||
}
|
||||
|
||||
if (m_sendPing)
|
||||
{
|
||||
nticksPing++;
|
||||
watch2.Start();
|
||||
|
||||
SendPing(udpClient);
|
||||
|
||||
watch2.Stop();
|
||||
avgSendPingTicks = (nticksPing - 1) / (float)nticksPing * avgSendPingTicks + (watch2.ElapsedTicks / (float)nticksPing);
|
||||
watch2.Reset();
|
||||
}
|
||||
|
||||
watch2.Start();
|
||||
// Dequeue any outgoing packets that are within the throttle limits
|
||||
if (udpClient.DequeueOutgoing())
|
||||
{
|
||||
m_packetSent = true;
|
||||
npacksSent++;
|
||||
}
|
||||
else
|
||||
{
|
||||
npackNotSent++;
|
||||
}
|
||||
|
||||
watch2.Stop();
|
||||
avgDequeueTicks = (nticks - 1) / (float)nticks * avgDequeueTicks + (watch2.ElapsedTicks / (float)nticks);
|
||||
watch2.Reset();
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
m_log.WarnFormat("[LLUDPSERVER]: Client is not connected");
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
m_log.Error("[LLUDPSERVER]: OutgoingPacketHandler iteration for " + client.Name +
|
||||
" threw an exception: " + ex.Message, ex);
|
||||
}
|
||||
watch1.Stop();
|
||||
avgProcessingTicks = (nticks - 1) / (float)nticks * avgProcessingTicks + (watch1.ElapsedTicks / (float)nticks);
|
||||
watch1.Reset();
|
||||
|
||||
// reuse this -- it's every ~100ms
|
||||
if (Scene.EmergencyMonitoring && nticks % 100 == 0)
|
||||
{
|
||||
m_log.InfoFormat("[LLUDPSERVER]: avg processing ticks: {0} avg unacked: {1} avg acks: {2} avg ping: {3} avg dequeue: {4} (TickCountRes: {5} sent: {6} notsent: {7})",
|
||||
avgProcessingTicks, avgResendUnackedTicks, avgSendAcksTicks, avgSendPingTicks, avgDequeueTicks, TickCountResolution, npacksSent, npackNotSent);
|
||||
npackNotSent = npacksSent = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
protected void ProcessInPacket(IncomingPacket incomingPacket)
|
||||
|
||||
@@ -92,8 +92,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||
Asset = throttleConfig.GetInt("asset_default", 10500);
|
||||
|
||||
Total = Resend + Land + Wind + Cloud + Task + Texture + Asset;
|
||||
// 3000000 bps default max
|
||||
ClientMaxRate = throttleConfig.GetInt("client_throttle_max_bps", 375000);
|
||||
// 5120000 bps default max
|
||||
ClientMaxRate = throttleConfig.GetInt("client_throttle_max_bps", 640000);
|
||||
if (ClientMaxRate > 1000000)
|
||||
ClientMaxRate = 1000000; // no more than 8Mbps
|
||||
|
||||
|
||||
@@ -62,8 +62,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||
/// </summary>
|
||||
protected const float m_minimumDripRate = 1500;
|
||||
|
||||
/// <summary>Time of the last drip, in system ticks</summary>
|
||||
protected Int32 m_lastDrip;
|
||||
/// <summary>Time of the last drip</summary>
|
||||
protected double m_lastDrip;
|
||||
|
||||
/// <summary>
|
||||
/// The number of bytes that can be sent at this moment. This is the
|
||||
@@ -166,10 +166,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||
/// </summary>
|
||||
protected float m_totalDripRequest;
|
||||
public float TotalDripRequest
|
||||
{
|
||||
get { return m_totalDripRequest; }
|
||||
set { m_totalDripRequest = value; }
|
||||
}
|
||||
{
|
||||
get { return m_totalDripRequest; }
|
||||
set { m_totalDripRequest = value; }
|
||||
}
|
||||
|
||||
#endregion Properties
|
||||
|
||||
@@ -193,9 +193,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||
Parent = parent;
|
||||
RequestedDripRate = dripRate;
|
||||
RequestedBurst = MaxBurst;
|
||||
// TotalDripRequest = dripRate; // this will be overwritten when a child node registers
|
||||
// MaxBurst = (Int64)((double)dripRate * m_quantumsPerBurst);
|
||||
m_lastDrip = Util.EnvironmentTickCount() + 100000;
|
||||
m_lastDrip = Util.GetTimeStampMS() + 50.0;
|
||||
}
|
||||
|
||||
#endregion Constructor
|
||||
@@ -210,7 +208,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||
protected float DripRateModifier()
|
||||
{
|
||||
float driprate = DripRate;
|
||||
return driprate >= TotalDripRequest ? 1.0f : driprate / TotalDripRequest;
|
||||
return driprate >= TotalDripRequest ? 1.0f : (driprate / TotalDripRequest);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -313,14 +311,14 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||
return;
|
||||
}
|
||||
|
||||
Int32 now = Util.EnvironmentTickCount();
|
||||
Int32 deltaMS = now - m_lastDrip;
|
||||
double now = Util.GetTimeStampMS();
|
||||
double deltaMS = now - m_lastDrip;
|
||||
m_lastDrip = now;
|
||||
|
||||
if (deltaMS <= 0)
|
||||
return;
|
||||
|
||||
m_tokenCount += deltaMS * DripRate * m_timeScale;
|
||||
m_tokenCount += (float)deltaMS * DripRate * m_timeScale;
|
||||
|
||||
float burst = Burst;
|
||||
if (m_tokenCount > burst)
|
||||
|
||||
Reference in New Issue
Block a user