Compare commits

...

9 Commits

Author SHA1 Message Date
UbitUmarov
b7da2feedd add cosmetics on AgentTransactionModule 2026-05-12 04:22:34 +01:00
UbitUmarov
88ef8a9dbe add Util.GetFirstConfigVarFromSections<T>(..) While GetConfigVarFromSections<T> scans all sections and returns the last value found, this returns as soon a value is found. So sections should be order from high priority to lower 2026-05-12 03:18:26 +01:00
UbitUmarov
9db019b2cc still read upload level from teh old position in Startup config, just in case 2026-05-11 17:46:57 +01:00
Ubit Umarov
f1b74cde60 Merge pull request #34 from holoneon/patch-1
Update AssetTransactionModule.cs
2026-05-11 17:15:41 +01:00
Fiona Sweet
d6fd012e65 Update AssetTransactionModule.cs
LevelUpload is defined in [Permissions] in OpenSimDefaults.ini, not [Startup]
2026-05-11 07:14:56 -07:00
UbitUmarov
64408c9395 avoid potencial on forced replace of files in flotsam cache problem 2026-05-02 00:06:47 +01:00
UbitUmarov
5b2ca76fcb avoid some future problem, thx Deiji 2026-04-30 05:53:46 +01:00
UbitUmarov
c6733b8c80 cosmetics on a blobfish 2026-04-27 19:40:51 +01:00
UbitUmarov
d068a68583 cosmetics 2026-04-27 14:06:55 +01:00
10 changed files with 160 additions and 124 deletions

View File

@@ -128,11 +128,10 @@ namespace OpenSim.Groups
Dictionary<string, object> request =
ServerUtils.ParseQueryString(body);
if (!request.ContainsKey("METHOD"))
if(!request.Remove("METHOD", out object omethod))
return FailureResult();
string method = request["METHOD"].ToString();
request.Remove("METHOD");
string method = omethod.ToString();
m_log.DebugFormat("[Groups.RobustHGConnector]: {0}", method);
switch (method)

View File

@@ -2232,9 +2232,9 @@ namespace OpenSim.Framework
/// <returns></returns>
public static T GetConfigVarFromSections<T>(IConfigSource config, string varname, string[] sections, object val)
{
foreach (string section in sections.AsSpan())
for (int i = 0 ; i < sections.Length; i++)
{
IConfig cnf = config.Configs[section];
IConfig cnf = config.Configs[sections[i]];
if (cnf == null)
continue;
@@ -2252,6 +2252,119 @@ namespace OpenSim.Framework
return (T)val;
}
/// <summary>
/// Gets the value of a configuration variable by looking into
/// multiple sections in order. Returns as soon one is found, ignoring other sections
/// </summary>
/// <remarks>
/// If no value is found then the given default value is returned
/// </remarks>
/// <typeparam name="T">Type of the variable</typeparam>
/// <param name="config">The configuration object</param>
/// <param name="varname">The configuration variable</param>
/// <param name="sections">Ordered sequence of sections to look at</param>
/// <param name="val">Default value</param>
/// <returns></returns>
public static T GetFirstConfigVarFromSections<T>(IConfigSource config, string varname, string[] sections, object val)
{
for (int i = 0 ; i < sections.Length; i++)
{
IConfig cnf = config.Configs[sections[i]];
if (cnf == null)
continue;
string text = cnf.Get(varname);
if (!string.IsNullOrEmpty(text))
{
if (typeof(T) == typeof(string))
return Unsafe.As<string, T>(ref text);
if (typeof(T) == typeof(bool))
{
bool b = bool.Parse(text);
return Unsafe.As<bool, T>(ref b);
}
if (typeof(T) == typeof(int))
{
int ti = int.Parse(text);
return Unsafe.As<int, T>(ref ti);
}
if (typeof(T) == typeof(float))
{
float f = float.Parse(text);
return Unsafe.As<float, T>(ref f);
}
if (typeof(T) == typeof(double))
{
double d = double.Parse(text);
return Unsafe.As<double, T>(ref d);
}
}
}
return val == null ? default : (T) val;
}
/// <summary>
/// Gets the value of a configuration variable by looking into
/// multiple sections in order. Returns as soon one is found, ignoring other sections
/// </summary>
/// <remarks>
/// If no value is found then the default value of T is returned
/// </remarks>
/// <typeparam name="T">Type of the variable</typeparam>
/// <param name="config">The configuration object</param>
/// <param name="varname">The configuration variable</param>
/// <param name="sections">Ordered sequence of sections to look at</param>
/// <returns></returns>
public static T GetFirstConfigVarFromSections<T>(IConfigSource config, string varname, string[] sections)
{
for (int i = 0 ; i < sections.Length; i++)
{
IConfig cnf = config.Configs[sections[i]];
if (cnf == null)
continue;
string text = cnf.Get(varname);
if (!string.IsNullOrEmpty(text))
{
if (typeof(T) == typeof(string))
return Unsafe.As<string, T>(ref text);
if (typeof(T) == typeof(bool))
{
bool b = bool.Parse(text);
return Unsafe.As<bool, T>(ref b);
}
if (typeof(T) == typeof(int))
{
int ti = int.Parse(text);
return Unsafe.As<int, T>(ref ti);
}
if (typeof(T) == typeof(float))
{
float f = float.Parse(text);
return Unsafe.As<float, T>(ref f);
}
if (typeof(T) == typeof(double))
{
double d = double.Parse(text);
return Unsafe.As<double, T>(ref d);
}
}
}
return default;
}
public static void MergeEnvironmentToConfig(IConfigSource ConfigSource)
{
IConfig enVars = ConfigSource.Configs["Environment"];

View File

@@ -100,16 +100,7 @@ namespace OpenSim.Region.ClientStack.Linden
IConfigSource config = m_Scene.Config;
if (config is not null)
{
IConfig sconfig = config.Configs["Startup"];
if (sconfig is not null)
ConfigOptions.levelUpload = sconfig.GetInt("LevelUpload", 0);
if (ConfigOptions.levelUpload == 0)
{
IConfig pconfig = config.Configs["Permissions"];
if (pconfig is not null)
ConfigOptions.levelUpload = pconfig.GetInt("LevelUpload", 0);
}
ConfigOptions.levelUpload = Util.GetFirstConfigVarFromSections<int>(config,"LevelUpload",["Permissions", "Startup"], 0);
IConfig appearanceConfig = config.Configs["Appearance"];
if (appearanceConfig is not null)

View File

@@ -305,11 +305,8 @@ namespace OpenSim.Region.ClientStack.Linden
{
lock(dropedResponses)
{
if(dropedResponses.Contains(requestID))
{
dropedResponses.Remove(requestID);
if(dropedResponses.Remove(requestID))
return;
}
}
}
@@ -321,9 +318,8 @@ namespace OpenSim.Region.ClientStack.Linden
{
lock(dropedResponses)
{
if(dropedResponses.Contains(requestID))
if(dropedResponses.Remove(requestID))
{
dropedResponses.Remove(requestID);
ProcessedRequestsCount++;
return;
}

View File

@@ -32,6 +32,7 @@ using OpenMetaverse;
using OpenMetaverse.Packets;
using log4net;
using OpenSim.Framework.Monitoring;
using System.Runtime.InteropServices;
namespace OpenSim.Region.ClientStack.LindenUDP
{
@@ -114,29 +115,24 @@ namespace OpenSim.Region.ClientStack.LindenUDP
public Packet GetPacket(PacketType type)
{
PacketsRequested++;
Packet packet;
if (!RecyclePackets)
return Packet.BuildPacket(type);
Packet packet;
lock (pool)
{
if (!pool.ContainsKey(type) || pool[type] == null || (pool[type]).Count == 0)
if (!pool.TryGetValue(type, out Stack<Packet> typePacketsStack) || typePacketsStack == null || typePacketsStack.Count == 0)
{
// m_log.DebugFormat("[PACKETPOOL]: Building {0} packet", type);
// Creating a new packet if we cannot reuse an old package
//m_log.DebugFormat("[PACKETPOOL]: Building {0} packet", type);
packet = Packet.BuildPacket(type);
}
else
{
// m_log.DebugFormat("[PACKETPOOL]: Pulling {0} packet", type);
//m_log.DebugFormat("[PACKETPOOL]: Pulling {0} packet", type);
// Recycle old packages
PacketsReused++;
packet = pool[type].Pop();
packet = typePacketsStack.Pop();
}
}
@@ -199,7 +195,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
if (!RecyclePackets)
return;
bool trypool = false;
PacketType type = packet.Type;
switch (type)
@@ -207,83 +202,33 @@ namespace OpenSim.Region.ClientStack.LindenUDP
case PacketType.ObjectUpdate:
ObjectUpdatePacket oup = (ObjectUpdatePacket)packet;
oup.ObjectData = null;
trypool = true;
break;
case PacketType.ImprovedTerseObjectUpdate:
ImprovedTerseObjectUpdatePacket itoup = (ImprovedTerseObjectUpdatePacket)packet;
itoup.ObjectData = null;
trypool = true;
break;
case PacketType.PacketAck:
PacketAckPacket ackup = (PacketAckPacket)packet;
ackup.Packets = null;
trypool = true;
break;
case PacketType.AgentUpdate:
trypool = true;
break;
default:
return;
}
if(!trypool)
return;
lock (pool)
{
if (!pool.ContainsKey(type))
ref Stack<Packet> spkt = ref CollectionsMarshal.GetValueRefOrAddDefault(pool, type, out bool exists);
if (exists && spkt.Count < 50)
{
pool[type] = new Stack<Packet>();
spkt.Push(packet);
return;
}
if ((pool[type]).Count < 50)
{
// m_log.DebugFormat("[PACKETPOOL]: Pushing {0} packet", type);
pool[type].Push(packet);
}
}
}
public T GetDataBlock<T>() where T: new()
{
lock (DataBlocks)
{
BlocksRequested++;
Stack<Object> s;
if (DataBlocks.TryGetValue(typeof(T), out s))
{
if (s.Count > 0)
{
BlocksReused++;
return (T)s.Pop();
}
}
else
{
DataBlocks[typeof(T)] = new Stack<Object>();
}
return new T();
}
}
public void ReturnDataBlock<T>(T block) where T: new()
{
if (block == null)
return;
lock (DataBlocks)
{
if (!DataBlocks.ContainsKey(typeof(T)))
DataBlocks[typeof(T)] = new Stack<Object>();
if (DataBlocks[typeof(T)].Count < 50)
DataBlocks[typeof(T)].Push(block);
spkt = new Stack<Packet>();
spkt.Push(packet);
}
}
}

View File

@@ -35,6 +35,7 @@ using OpenSim.Framework;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes;
using Mono.Addins;
using System.Runtime.InteropServices;
namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
{
@@ -51,18 +52,14 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
/// <summary>
/// Each agent has its own singleton collection of transactions
/// </summary>
private Dictionary<UUID, AgentAssetTransactions> AgentTransactions =
new Dictionary<UUID, AgentAssetTransactions>();
private Dictionary<UUID, AgentAssetTransactions> AgentTransactions = [];
#region Region Module interface
public void Initialise(IConfigSource source)
{
IConfig sconfig = source.Configs["Startup"];
if (sconfig != null)
{
m_levelUpload = sconfig.GetInt("LevelUpload", 0);
}
if(source != null)
m_levelUpload = Util.GetFirstConfigVarFromSections<int>(source,"LevelUpload",["Permissions", "Startup"], 0);
}
public void AddRegion(Scene scene)
@@ -113,16 +110,11 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
{
lock (AgentTransactions)
{
if (!AgentTransactions.ContainsKey(userID))
{
AgentAssetTransactions transactions =
new AgentAssetTransactions(userID, m_Scene,
m_dumpAssetsToFile);
ref AgentAssetTransactions value = ref CollectionsMarshal.GetValueRefOrAddDefault(AgentTransactions, userID, out bool exists);
if (!exists)
value = new AgentAssetTransactions(userID, m_Scene, m_dumpAssetsToFile);
AgentTransactions.Add(userID, transactions);
}
return AgentTransactions[userID];
return value;
}
}
@@ -217,8 +209,7 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
// "[ASSET TRANSACTION MODULE]: Called HandleTaskItemUpdateFromTransaction with item {0} in {1} for {2} in {3}",
// item.Name, part.Name, remoteClient.Name, m_Scene.RegionInfo.RegionName);
AgentAssetTransactions transactions =
GetUserTransactions(remoteClient.AgentId);
AgentAssetTransactions transactions = GetUserTransactions(remoteClient.AgentId);
transactions.RequestUpdateTaskInventoryItem(remoteClient, part,
transactionID, item);
@@ -247,9 +238,8 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
(AssetType)type == AssetType.Animation) &&
tempFile == false)
{
ScenePresence avatar = null;
Scene scene = (Scene)remoteClient.Scene;
scene.TryGetScenePresence(remoteClient.AgentId, out avatar);
scene.TryGetScenePresence(remoteClient.AgentId, out ScenePresence avatar);
// check user level
if (avatar != null)

View File

@@ -994,7 +994,8 @@ namespace OpenSim.Region.CoreModules.Asset
try
{
// If the file is already cached, don't cache it, just touch it so access time is updated
if (!replace && File.Exists(filename))
bool fileExists = File.Exists(filename);
if (!replace && fileExists)
{
if (m_updateFileTimeOnCacheHit)
UpdateFileLastAccessTime(filename);
@@ -1031,7 +1032,7 @@ namespace OpenSim.Region.CoreModules.Asset
try
{
if(replace)
if(fileExists)
File.Delete(filename);
File.Move(tempname, filename);
}

View File

@@ -29,6 +29,7 @@ using System;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Text;
using System.Text.RegularExpressions;
using System.Xml;
@@ -147,15 +148,14 @@ namespace OpenSim.Region.DataSnapshot
#region Response storage
public XmlNode GetScene(Scene scene, XmlDocument factory)
{
m_log.Debug("[DATASNAPSHOT]: Data requested for scene " + scene.RegionInfo.RegionName);
m_log.Debug("[DATASNAPSHOT]: Data requested for scene " + scene.Name);
if (!m_scenes.ContainsKey(scene)) {
m_scenes.Add(scene, true); //stale by default
}
ref bool sceneStale = ref CollectionsMarshal.GetValueRefOrAddDefault(m_scenes, scene, out bool exists);
sceneStale |= !exists;
XmlNode regionElement = null;
if (!m_scenes[scene])
if (!sceneStale)
{
m_log.Debug("[DATASNAPSHOT]: Attempting to retrieve snapshot from cache.");
//get snapshot from cache
@@ -212,7 +212,7 @@ namespace OpenSim.Region.DataSnapshot
m_log.WarnFormat("[DATASNAPSHOT]: Exception on writing to file {0}: {1}", path, e.Message);
}
m_scenes[scene] = false;
sceneStale = false;
m_log.Debug("[DATASNAPSHOT]: Generated new snapshot for " + scene.RegionInfo.RegionName);
}
@@ -258,7 +258,6 @@ namespace OpenSim.Region.DataSnapshot
//attr.Value = scene.LandManager.landList.Count.ToString();
//docElement.Attributes.Append(attr);
XmlNode infoblock = basedoc.CreateNode(XmlNodeType.Element, "info", "");
XmlNode infopiece = basedoc.CreateNode(XmlNodeType.Element, "uuid", "");

View File

@@ -2942,7 +2942,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine
if(obj is OTOpndBinOp)
sb.Append(')');
sb.Append('.');
sb.Append(field.Name);
sb.Append(this.field.Name);
return sb.ToString();
}
}
@@ -3548,9 +3548,9 @@ namespace OpenSim.Region.ScriptEngine.Yengine
{
get
{
if(field.DeclaringType == typeof(ScriptBaseClass))
return field.Name;
return field.DeclaringType.Name + "." + field.Name;
if(this.field.DeclaringType == typeof(ScriptBaseClass))
return this.field.Name;
return this.field.DeclaringType.Name + "." + this.field.Name;
}
}
}

View File

@@ -450,9 +450,11 @@ namespace OpenSim.Services.LLLoginService
//
// Authenticate this user
//
if (!passwd.StartsWith("$1$"))
passwd = "$1$" + Util.Md5Hash(passwd);
passwd = passwd.Remove(0, 3); //remove $1$
if (passwd.StartsWith("$1$"))
passwd = passwd[3..];
else
passwd = Util.Md5Hash(passwd);
string token = m_AuthenticationService.Authenticate(account.PrincipalID, passwd, 30, out UUID realID);
UUID secureSession = UUID.Zero;
if (string.IsNullOrWhiteSpace(token) || !UUID.TryParse(token, out secureSession))