aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs
diff options
context:
space:
mode:
authorTedd Hansen2007-08-25 20:34:54 +0000
committerTedd Hansen2007-08-25 20:34:54 +0000
commit80234b98e5dd03de08229fb5cc6dd2a42e70ec24 (patch)
treefcc566aa0855c79655a5749be245cd16db7cd5aa /OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs
parentTest to see if this change improves or makes worse the texture sending bug (diff)
downloadopensim-SC_OLD-80234b98e5dd03de08229fb5cc6dd2a42e70ec24.zip
opensim-SC_OLD-80234b98e5dd03de08229fb5cc6dd2a42e70ec24.tar.gz
opensim-SC_OLD-80234b98e5dd03de08229fb5cc6dd2a42e70ec24.tar.bz2
opensim-SC_OLD-80234b98e5dd03de08229fb5cc6dd2a42e70ec24.tar.xz
Removal of script that was unable to compile no longer crashes server.
Displays script compile error messages in-world.
Diffstat (limited to 'OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs')
-rw-r--r--OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs51
1 files changed, 40 insertions, 11 deletions
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs
index 29171a1..bf863b8 100644
--- a/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs
+++ b/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs
@@ -245,6 +245,8 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
245 // It will be up to the script itself to hook up the correct events. 245 // It will be up to the script itself to hook up the correct events.
246 string FileName = ""; 246 string FileName = "";
247 247
248 IScriptHost m_host = World.GetSceneObjectPart(localID);
249
248 try 250 try
249 { 251 {
250 252
@@ -264,7 +266,8 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
264 long before; 266 long before;
265 before = GC.GetTotalMemory(false); 267 before = GC.GetTotalMemory(false);
266#endif 268#endif
267 LSL_BaseClass CompiledScript = m_scriptEngine.myAppDomainManager.LoadScript(FileName); 269 LSL_BaseClass CompiledScript;
270 CompiledScript = m_scriptEngine.myAppDomainManager.LoadScript(FileName);
268#if DEBUG 271#if DEBUG
269 Console.WriteLine("Script " + itemID + " occupies {0} bytes", GC.GetTotalMemory(false) - before); 272 Console.WriteLine("Script " + itemID + " occupies {0} bytes", GC.GetTotalMemory(false) - before);
270#endif 273#endif
@@ -274,7 +277,9 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
274 277
275 // We need to give (untrusted) assembly a private instance of BuiltIns 278 // We need to give (untrusted) assembly a private instance of BuiltIns
276 // this private copy will contain Read-Only FullitemID so that it can bring that on to the server whenever needed. 279 // this private copy will contain Read-Only FullitemID so that it can bring that on to the server whenever needed.
277 LSL_BuiltIn_Commands LSLB = new LSL_BuiltIn_Commands(m_scriptEngine, World.GetSceneObjectPart(localID), localID, itemID); 280
281
282 LSL_BuiltIn_Commands LSLB = new LSL_BuiltIn_Commands(m_scriptEngine, m_host, localID, itemID);
278 283
279 // Start the script - giving it BuiltIns 284 // Start the script - giving it BuiltIns
280 CompiledScript.Start(LSLB); 285 CompiledScript.Start(LSLB);
@@ -286,8 +291,21 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
286 } 291 }
287 catch (Exception e) 292 catch (Exception e)
288 { 293 {
289 m_scriptEngine.Log.Error("ScriptEngine", "Exception loading script \"" + FileName + "\": " + e.ToString()); 294 m_scriptEngine.Log.Error("ScriptEngine", "Error compiling script: " + e.ToString());
295 try
296 {
297 // DISPLAY ERROR INWORLD
298 string text = "Error compiling script:\r\n" + e.Message.ToString();
299 if (text.Length > 1500)
300 text = text.Substring(0, 1500);
301 World.SimChat(Helpers.StringToField(text), 1, m_host.AbsolutePosition, m_host.Name, m_host.UUID);
302 }
303 catch (Exception e2)
304 {
305 m_scriptEngine.Log.Error("ScriptEngine", "Error displaying error in-world: " + e2.ToString());
306 }
290 } 307 }
308
291 309
292 310
293 } 311 }
@@ -300,14 +318,25 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
300 // Stop long command on script 318 // Stop long command on script
301 m_scriptEngine.myLSLLongCmdHandler.RemoveScript(localID, itemID); 319 m_scriptEngine.myLSLLongCmdHandler.RemoveScript(localID, itemID);
302 320
303 // Get AppDomain 321 LSL_BaseClass LSLBC = GetScript(localID, itemID);
304 AppDomain ad = GetScript(localID, itemID).Exec.GetAppDomain(); 322 if (LSLBC == null)
305 // Tell script not to accept new requests 323 return;
306 GetScript(localID, itemID).Exec.StopScript(); 324
307 // Remove from internal structure 325 try
308 RemoveScript(localID, itemID); 326 {
309 // Tell AppDomain that we have stopped script 327 // Get AppDomain
310 m_scriptEngine.myAppDomainManager.StopScript(ad); 328 AppDomain ad = LSLBC.Exec.GetAppDomain();
329 // Tell script not to accept new requests
330 GetScript(localID, itemID).Exec.StopScript();
331 // Remove from internal structure
332 RemoveScript(localID, itemID);
333 // Tell AppDomain that we have stopped script
334 m_scriptEngine.myAppDomainManager.StopScript(ad);
335 }
336 catch(Exception e)
337 {
338 Console.WriteLine("Exception stopping script localID: " + localID + " LLUID: " + itemID.ToString() + ": " + e.ToString());
339 }
311 } 340 }
312 private string ProcessYield(string FileName) 341 private string ProcessYield(string FileName)
313 { 342 {