From fcb34efa95ebdd3200cfb9100329a544c6db658e Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 26 Jun 2012 10:47:35 +0200 Subject: [PATCH 1/7] Prevent bad prim in the database from crashing the sim, list affected ids and skip them. --- OpenSim/Data/MySQL/MySQLSimulationData.cs | 50 +++++++++++++---------- 1 file changed, 29 insertions(+), 21 deletions(-) diff --git a/OpenSim/Data/MySQL/MySQLSimulationData.cs b/OpenSim/Data/MySQL/MySQLSimulationData.cs index 1999d899c2..5e4df3a37d 100644 --- a/OpenSim/Data/MySQL/MySQLSimulationData.cs +++ b/OpenSim/Data/MySQL/MySQLSimulationData.cs @@ -1269,32 +1269,40 @@ namespace OpenSim.Data.MySQL /// private static TaskInventoryItem BuildItem(IDataReader row) { - TaskInventoryItem taskItem = new TaskInventoryItem(); + try + { + TaskInventoryItem taskItem = new TaskInventoryItem(); - taskItem.ItemID = DBGuid.FromDB(row["itemID"]); - taskItem.ParentPartID = DBGuid.FromDB(row["primID"]); - taskItem.AssetID = DBGuid.FromDB(row["assetID"]); - taskItem.ParentID = DBGuid.FromDB(row["parentFolderID"]); + taskItem.ItemID = DBGuid.FromDB(row["itemID"]); + taskItem.ParentPartID = DBGuid.FromDB(row["primID"]); + taskItem.AssetID = DBGuid.FromDB(row["assetID"]); + taskItem.ParentID = DBGuid.FromDB(row["parentFolderID"]); - taskItem.InvType = Convert.ToInt32(row["invType"]); - taskItem.Type = Convert.ToInt32(row["assetType"]); + taskItem.InvType = Convert.ToInt32(row["invType"]); + taskItem.Type = Convert.ToInt32(row["assetType"]); - taskItem.Name = (String)row["name"]; - taskItem.Description = (String)row["description"]; - taskItem.CreationDate = Convert.ToUInt32(row["creationDate"]); - taskItem.CreatorIdentification = (String)row["creatorID"]; - taskItem.OwnerID = DBGuid.FromDB(row["ownerID"]); - taskItem.LastOwnerID = DBGuid.FromDB(row["lastOwnerID"]); - taskItem.GroupID = DBGuid.FromDB(row["groupID"]); + taskItem.Name = (String)row["name"]; + taskItem.Description = (String)row["description"]; + taskItem.CreationDate = Convert.ToUInt32(row["creationDate"]); + taskItem.CreatorIdentification = (String)row["creatorID"]; + taskItem.OwnerID = DBGuid.FromDB(row["ownerID"]); + taskItem.LastOwnerID = DBGuid.FromDB(row["lastOwnerID"]); + taskItem.GroupID = DBGuid.FromDB(row["groupID"]); - taskItem.NextPermissions = Convert.ToUInt32(row["nextPermissions"]); - taskItem.CurrentPermissions = Convert.ToUInt32(row["currentPermissions"]); - taskItem.BasePermissions = Convert.ToUInt32(row["basePermissions"]); - taskItem.EveryonePermissions = Convert.ToUInt32(row["everyonePermissions"]); - taskItem.GroupPermissions = Convert.ToUInt32(row["groupPermissions"]); - taskItem.Flags = Convert.ToUInt32(row["flags"]); + taskItem.NextPermissions = Convert.ToUInt32(row["nextPermissions"]); + taskItem.CurrentPermissions = Convert.ToUInt32(row["currentPermissions"]); + taskItem.BasePermissions = Convert.ToUInt32(row["basePermissions"]); + taskItem.EveryonePermissions = Convert.ToUInt32(row["everyonePermissions"]); + taskItem.GroupPermissions = Convert.ToUInt32(row["groupPermissions"]); + taskItem.Flags = Convert.ToUInt32(row["flags"]); - return taskItem; + return taskItem; + } + catch + { + m_log.ErrorFormat("[MYSQL DB]: Error reading task inventory: itemID was {0}, primID was {1}", row["itemID"].ToString(), row["primID"].ToString()); + throw; + } } private static RegionSettings BuildRegionSettings(IDataReader row) From 2ea8d820b025b6945bde3d84caec9345585c3592 Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 26 Jun 2012 10:48:27 +0200 Subject: [PATCH 2/7] Correct a wrong error constant --- OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs index 278f74e525..ad4f70c21b 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs @@ -667,7 +667,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase public static readonly LSLInteger RCERR_UNKNOWN = -1; public static readonly LSLInteger RCERR_SIM_PERF_LOW = -2; - public static readonly LSLInteger RCERR_CAST_TIME_EXCEEDED = 3; + public static readonly LSLInteger RCERR_CAST_TIME_EXCEEDED = -3; public const int KFM_MODE = 1; public const int KFM_LOOP = 1; From 2548d158783cd15b44cb485c10894740cbdb3efe Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 26 Jun 2012 10:48:52 +0200 Subject: [PATCH 3/7] Disable physics raycast until it can be seen to. Fix distance calculation for some results. --- .../Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index fe8511843d..a0dc6cd1b8 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -12379,9 +12379,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api ContactResult result = new ContactResult (); result.ConsumerID = group.LocalId; - result.Depth = intersection.distance; +// result.Depth = intersection.distance; result.Normal = intersection.normal; result.Pos = intersection.ipoint; + result.Depth = Vector3.Mag(rayStart - result.Pos); contacts.Add(result); }); @@ -12576,7 +12577,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api bool checkPhysical = !((rejectTypes & ScriptBaseClass.RC_REJECT_PHYSICAL) == ScriptBaseClass.RC_REJECT_PHYSICAL); - if (World.SuportsRayCastFiltered()) + if (false)// World.SuportsRayCastFiltered()) { if (dist == 0) return list; From 9a8de52940ea6d9ce430d8d51094a353eca7d3c5 Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 26 Jun 2012 10:49:37 +0200 Subject: [PATCH 4/7] Add an event to the poll service manager thread to allow starting it when needed rather than once per second. That is just too slow! --- .../Servers/HttpServer/PollServiceRequestManager.cs | 7 +++++-- .../Servers/HttpServer/PollServiceWorkerThread.cs | 11 +++++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs b/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs index 0062d4ef15..c3e1a79f94 100644 --- a/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs +++ b/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs @@ -41,6 +41,7 @@ namespace OpenSim.Framework.Servers.HttpServer private readonly BaseHttpServer m_server; private static Queue m_requests = Queue.Synchronized(new Queue()); + private static ManualResetEvent m_ev = new ManualResetEvent(false); private uint m_WorkerThreadCount = 0; private Thread[] m_workerThreads; private PollServiceWorkerThread[] m_PollServiceWorkerThreads; @@ -88,15 +89,17 @@ namespace OpenSim.Framework.Servers.HttpServer { lock (m_requests) m_requests.Enqueue(req); + m_ev.Set(); } public void ThreadStart() { while (m_running) { + m_ev.WaitOne(1000); + m_ev.Reset(); Watchdog.UpdateThread(); ProcessQueuedRequests(); - Thread.Sleep(1000); } } @@ -152,4 +155,4 @@ namespace OpenSim.Framework.Servers.HttpServer m_running = false; } } -} \ No newline at end of file +} diff --git a/OpenSim/Framework/Servers/HttpServer/PollServiceWorkerThread.cs b/OpenSim/Framework/Servers/HttpServer/PollServiceWorkerThread.cs index 5e171f00f8..b39185fba9 100644 --- a/OpenSim/Framework/Servers/HttpServer/PollServiceWorkerThread.cs +++ b/OpenSim/Framework/Servers/HttpServer/PollServiceWorkerThread.cs @@ -89,9 +89,16 @@ namespace OpenSim.Framework.Servers.HttpServer continue; } - Hashtable responsedata = req.PollServiceArgs.GetEvents(req.RequestID, req.PollServiceArgs.Id, str.ReadToEnd()); - m_server.DoHTTPGruntWork(responsedata, + try + { + Hashtable responsedata = req.PollServiceArgs.GetEvents(req.RequestID, req.PollServiceArgs.Id, str.ReadToEnd()); + m_server.DoHTTPGruntWork(responsedata, new OSHttpResponse(new HttpResponse(req.HttpContext, req.Request),req.HttpContext)); + } + catch (ObjectDisposedException) // Browser aborted before we could read body, server closed the stream + { + // Ignore it, no need to reply + } } else { From 625041f1db90c5a7f917f52720199ee0088a3141 Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 27 Jun 2012 00:10:51 +0200 Subject: [PATCH 5/7] Comment out a spammy message that will spew 4 lines for each request to a nonexistent URL for http-in --- OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs index f4cf6b4d98..a701b46db8 100644 --- a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs @@ -508,7 +508,8 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp } else { - m_log.Warn("[HttpRequestHandler]: http-in request failed; no such url: "+urlkey.ToString()); + //m_log.Warn("[HttpRequestHandler]: http-in request failed; no such url: "+urlkey.ToString()); + return; } //for llGetHttpHeader support we need to store original URI here From 8a03c153d52302ec83342e93f67c99afd9de31ac Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 28 Jun 2012 20:29:37 +0200 Subject: [PATCH 6/7] Return NPC instead of AGENT in the detect parameters for touch, collision and sensor. --- OpenSim/Region/ScriptEngine/Shared/Helpers.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/OpenSim/Region/ScriptEngine/Shared/Helpers.cs b/OpenSim/Region/ScriptEngine/Shared/Helpers.cs index 7e7e278f2c..5c9d30f80c 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Helpers.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Helpers.cs @@ -197,6 +197,8 @@ namespace OpenSim.Region.ScriptEngine.Shared presence.Velocity.Z); Type = 0x01; // Avatar + if (presence.PresenceType == PresenceType.Npc) + Type = 0x20; if (presence.Velocity != Vector3.Zero) Type |= 0x02; // Active From c87f0ac2261d1aa5226957aff63bfc8ac0efaffd Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 28 Jun 2012 21:23:42 +0200 Subject: [PATCH 7/7] Fix llRegionSayTo the right way --- OpenSim/Framework/OSChatMessage.cs | 7 +++++++ .../CoreModules/Avatar/Chat/ChatModule.cs | 11 +++++++++-- .../Scripting/WorldComm/WorldCommModule.cs | 19 ++++++++++++------- .../Framework/Scenes/Scene.PacketHandlers.cs | 11 +++++++++-- 4 files changed, 37 insertions(+), 11 deletions(-) diff --git a/OpenSim/Framework/OSChatMessage.cs b/OpenSim/Framework/OSChatMessage.cs index 54fa2756d2..7450be2f9d 100644 --- a/OpenSim/Framework/OSChatMessage.cs +++ b/OpenSim/Framework/OSChatMessage.cs @@ -51,6 +51,7 @@ namespace OpenSim.Framework protected object m_senderObject; protected ChatTypeEnum m_type; protected UUID m_fromID; + protected UUID m_destination = UUID.Zero; public OSChatMessage() { @@ -131,6 +132,12 @@ namespace OpenSim.Framework set { m_fromID = value; } } + public UUID Destination + { + get { return m_destination; } + set { m_destination = value; } + } + /// /// /// diff --git a/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs b/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs index 4d8fb90eb0..357c2af421 100644 --- a/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs @@ -199,6 +199,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat UUID fromID = UUID.Zero; string message = c.Message; IScene scene = c.Scene; + UUID destination = c.Destination; Vector3 fromPos = c.Position; Vector3 regionPos = new Vector3(scene.RegionInfo.RegionLocX * Constants.RegionSize, scene.RegionInfo.RegionLocY * Constants.RegionSize, 0); @@ -222,6 +223,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat { fromNamePrefix = m_adminPrefix; } + destination = UUID.Zero; // Avatars cant "SayTo" break; case ChatSourceType.Object: @@ -244,9 +246,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat { // This should use ForEachClient, but clients don't have a position. // If camera is moved into client, then camera position can be used + // MT: No, it can't, as chat is heard from the avatar position, not + // the camera position. s.ForEachRootScenePresence( delegate(ScenePresence presence) { + if (destination != UUID.Zero && presence.UUID != destination) + return; ILandObject Presencecheck = s.LandChannel.GetLandObject(presence.AbsolutePosition.X, presence.AbsolutePosition.Y); if (Presencecheck != null) { @@ -346,8 +352,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat UUID fromAgentID, string fromName, ChatTypeEnum type, string message, ChatSourceType src) { - // don't send stuff to child agents - if (presence.IsChildAgent) return false; + // don't send llRegionSay to child agents. Send normal chat because you + // can't talk across sim borders if it's not done + if (type == ChatTypeEnum.Broadcast && presence.IsChildAgent) return false; Vector3 fromRegionPos = fromPos + regionPos; Vector3 toRegionPos = presence.AbsolutePosition + diff --git a/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs b/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs index 176c86de12..07bb291241 100644 --- a/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs @@ -90,6 +90,8 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm // private static readonly ILog m_log = // LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + private const int DEBUG_CHANNEL = 2147483647; + private ListenerManager m_listenerManager; private Queue m_pending; private Queue m_pendingQ; @@ -311,6 +313,10 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm public bool DeliverMessageTo(UUID target, int channel, Vector3 pos, string name, UUID id, string msg, out string error) { error = null; + + if (channel == DEBUG_CHANNEL) + return true; + // Is id an avatar? ScenePresence sp = m_scene.GetScenePresence(target); @@ -319,7 +325,9 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm // Send message to avatar if (channel == 0) { - m_scene.SimChatBroadcast(Utils.StringToBytes(msg), ChatTypeEnum.Broadcast, 0, pos, name, id, false); + // Channel 0 goes to viewer ONLY + m_scene.SimChat(Utils.StringToBytes(msg), ChatTypeEnum.Broadcast, 0, pos, name, id, false, false, target); + return true; } List attachments = sp.GetAttachments(); @@ -351,12 +359,9 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm return true; } - // Need to toss an error here - if (channel == 0) - { - error = "Cannot use llRegionSayTo to message objects on channel 0"; - return false; - } + SceneObjectPart part = m_scene.GetSceneObjectPart(target); + if (part == null) // Not even an object + return true; // No error foreach (ListenerInfo li in m_listenerManager.GetListeners(UUID.Zero, channel, name, id, msg)) { diff --git a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs index 3ef1e29782..431b90302a 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs @@ -38,8 +38,8 @@ namespace OpenSim.Region.Framework.Scenes { public partial class Scene { - protected void SimChat(byte[] message, ChatTypeEnum type, int channel, Vector3 fromPos, string fromName, - UUID fromID, bool fromAgent, bool broadcast) + public void SimChat(byte[] message, ChatTypeEnum type, int channel, Vector3 fromPos, string fromName, + UUID fromID, bool fromAgent, bool broadcast, UUID destination) { OSChatMessage args = new OSChatMessage(); @@ -49,6 +49,7 @@ namespace OpenSim.Region.Framework.Scenes args.Position = fromPos; args.SenderUUID = fromID; args.Scene = this; + args.Destination = destination; if (fromAgent) { @@ -71,6 +72,12 @@ namespace OpenSim.Region.Framework.Scenes EventManager.TriggerOnChatFromWorld(this, args); } + protected void SimChat(byte[] message, ChatTypeEnum type, int channel, Vector3 fromPos, string fromName, + UUID fromID, bool fromAgent, bool broadcast) + { + SimChat(message, type, channel, fromPos, fromName, fromID, fromAgent, broadcast, UUID.Zero); + } + /// /// ///