add AddOpenSimExtraFeature to simulator features, so it is done under proper locking. Fix gridservice extra features merge (they override older). This does need a future cleanup

master
UbitUmarov 2020-05-08 16:54:18 +01:00
parent 72c1c923f8
commit fa5b4dc5d8
3 changed files with 29 additions and 16 deletions

View File

@ -235,6 +235,22 @@ namespace OpenSim.Region.ClientStack.Linden
m_features[name] = value; m_features[name] = value;
} }
public void AddOpenSimExtraFeature(string name, OSD value)
{
lock (m_features)
{
OSDMap extrasMap;
if (m_features.TryGetValue("OpenSimExtras", out OSD extra))
extrasMap = extra as OSDMap;
else
{
extrasMap = new OSDMap();
}
extrasMap[name] = value;
m_features["OpenSimExtras"] = extrasMap;
}
}
public bool RemoveFeature(string name) public bool RemoveFeature(string name)
{ {
lock (m_features) lock (m_features)
@ -315,9 +331,15 @@ namespace OpenSim.Region.ClientStack.Linden
lock (m_features) lock (m_features)
{ {
OSDMap extrasMap = new OSDMap(); OSDMap extrasMap;
if (m_features.TryGetValue("OpenSimExtras", out OSD extra))
extrasMap = extra as OSDMap;
else
{
extrasMap = new OSDMap();
}
foreach(string key in extraFeatures.Keys) foreach (string key in extraFeatures.Keys)
{ {
extrasMap[key] = (string)extraFeatures[key]; extrasMap[key] = (string)extraFeatures[key];
@ -327,7 +349,6 @@ namespace OpenSim.Region.ClientStack.Linden
} }
} }
m_features["OpenSimExtras"] = extrasMap; m_features["OpenSimExtras"] = extrasMap;
} }
} }

View File

@ -40,6 +40,7 @@ namespace OpenSim.Region.Framework.Interfaces
{ {
event SimulatorFeaturesRequestDelegate OnSimulatorFeaturesRequest; event SimulatorFeaturesRequestDelegate OnSimulatorFeaturesRequest;
void AddFeature(string name, OSD value); void AddFeature(string name, OSD value);
void AddOpenSimExtraFeature(string name, OSD value);
bool RemoveFeature(string name); bool RemoveFeature(string name);
bool TryGetFeature(string name, out OSD value); bool TryGetFeature(string name, out OSD value);
OSDMap GetFeatures(); OSDMap GetFeatures();

View File

@ -1255,23 +1255,14 @@ namespace OpenSim.Region.Framework.Scenes
ISimulatorFeaturesModule fm = RequestModuleInterface<ISimulatorFeaturesModule>(); ISimulatorFeaturesModule fm = RequestModuleInterface<ISimulatorFeaturesModule>();
if (fm != null) if (fm != null)
{ {
OSD openSimExtras;
OSDMap openSimExtrasMap;
if (!fm.TryGetFeature("OpenSimExtras", out openSimExtras))
openSimExtras = new OSDMap();
float statisticsFPSfactor = 1.0f; float statisticsFPSfactor = 1.0f;
if(Normalized55FPS) if(Normalized55FPS)
statisticsFPSfactor = 55.0f * FrameTime; statisticsFPSfactor = 55.0f * FrameTime;
openSimExtrasMap = (OSDMap)openSimExtras; fm.AddOpenSimExtraFeature("SimulatorFPS", OSD.FromReal(1.0f / FrameTime));
openSimExtrasMap["SimulatorFPS"] = OSD.FromReal(1.0f / FrameTime); fm.AddOpenSimExtraFeature("SimulatorFPSFactor", OSD.FromReal(statisticsFPSfactor));
openSimExtrasMap["SimulatorFPSFactor"] = OSD.FromReal(statisticsFPSfactor); fm.AddOpenSimExtraFeature("SimulatorFPSWarnPercent", OSD.FromInteger(FrameTimeWarnPercent));
openSimExtrasMap["SimulatorFPSWarnPercent"] = OSD.FromInteger(FrameTimeWarnPercent); fm.AddOpenSimExtraFeature("SimulatorFPSCritPercent", OSD.FromInteger(FrameTimeCritPercent));
openSimExtrasMap["SimulatorFPSCritPercent"] = OSD.FromInteger(FrameTimeCritPercent);
fm.AddFeature("OpenSimExtras", openSimExtrasMap);
} }
} }