Commit Graph

259 Commits (741caee04017afdef55fdf08dcc651f44f1b4782)

Author SHA1 Message Date
Justin Clark-Casey (justincc) e7f1695338 Correct typo in raw default script stop strategy 2015-01-29 19:11:06 +00:00
Justin Clark-Casey (justincc) bd962f7e07 If an exception comes out of DoOnRezScript in DoOnRezScriptQueue(), then only fail a single script rather than halting the exntire script startup process. 2015-01-29 19:10:51 +00:00
Justin Clark-Casey (justincc) 979afbd748 Make XEngine.SaveAllState() actually do this instead of script maintenance 2015-01-29 19:08:49 +00:00
Justin Clark-Casey (justincc) d748c0896d minor: remove old commented out objectRemoved bool in XEngine.OnRemoveScript() 2015-01-29 19:08:38 +00:00
Justin Clark-Casey (justincc) 7317092733 For scripts in attachments, don't save .state files apart from the initial one as these are ignored since .state is saved in the attachment's asset.
This eliminates pointless work and exceptions when an appdomain is unloaded whilst an attachment script state is persisted.
Adds test for this case.
Relates to http://opensimulator.org/mantis/view.php?id=7407
2015-01-29 19:08:30 +00:00
Diva Canto 7466ef0525 This cleans up versioning. Specifically:
- It establishes 4 digits for opensim versions
- It uses the same number between opensim releases and mono addins versions

It also eliminates the last addin.xml files that were still there, for consistency.
2014-12-30 12:53:31 -08:00
Justin Clark-Casey (justincc) 147d401b28 Remove XEngine.m_uniqueScripts
This provides no obvious benefit as far as I can tell but has a definite cost in keep script strings in memory for the entire simulator session.
2014-12-15 20:38:26 +00:00
Justin Clark-Casey (justincc) 2b9f0647de Fix a regression where objects crossing regions in the same simulator (on their own or as attachments) with AppDomainLoading = false would create the new state in the source region area rather than the dest.
This was beause the code was finding the script DLL compiled for the source region as everything is in the same appdomain and using this as the location for the destination script state, etc.
This resolves the regression by passing the proper destination separately from the DLL retrieved.
Probably a regression since commit d7b92604 (11 July 2014).
Added regression test for this case.
At least partly addresses http://opensimulator.org/mantis/view.php?id=7278
2014-12-10 00:25:27 +00:00
Justin Clark-Casey (justincc) 227d2e2b61 Avoid a possible race condition where the XEngine script compile thread could complete but see OnRezScript() insert a new job and complete before it set m_CurrentCompile = null
If the above happened, it would mean the new script would not compile until some  script was added for compilation.
2014-12-10 00:04:10 +00:00
Justin Clark-Casey (justincc) 76722d8324 In XEngine, enqueue a script rez to the compile queue after setting m_CompileDict to avoid a rare but not impossible race condition. 2014-12-09 23:59:19 +00:00
Justin Clark-Casey (justincc) d34ad345d5 minor: If we are recompiling scripts in response to a ScriptStopStrategy config change (a rare situation), then explicitly log this for debug purposes. 2014-12-03 21:08:43 +00:00
Justin Clark-Casey (justincc) c3c05a8693 Reintroduce general xengine extra debugging log level. This can be controlled at runtime with the command "debug xengine log <level>", as with similar commands.
If log level is 1 then every script load is logged.
This means the <logger name="OpenSim.Region.ScriptEngine.XEngine"> section in OpenSim.exe.config is no longer needed to avoid log spam on regions with many scripts and can be removed.
2014-12-03 20:48:17 +00:00
Justin Clark-Casey (justincc) 805b7ccb3e minor: improve logged error in XEngine.SetXmlState if there was a problem writing the linemap.
The previous error report of already exists is inaccurate since existing files do get overwritten.
2014-12-03 20:35:49 +00:00
Justin Clark-Casey (justincc) 432f0e8783 Correct 690fe0c to actually log the exception reported in DoOnRezScriptQueue()(and now the scene name). 2014-11-29 15:04:16 +00:00
Justin Clark-Casey (justincc) 690fe0c5e5 If there are any exceptions in XEngine.DoOnRezScriptQueue() then log the error and always set m_CurrentCompile = null
Setting m_CurrentCompile = null in the finally block reduces the risk that an exception could permanently stop any future scripts compiling until the simulator is restarted.
If an exception is seen from this then please report and further changes to fix the bug or improve compiling reliability can be made.
2014-11-29 01:42:52 +00:00
Justin Clark-Casey (justincc) 55e064baf7 Remove minor race condition where two threads could race on fields such as m_ScriptFailCount as set in XEngine.DoOnRezScriptQueue() 2014-11-29 01:33:14 +00:00
Justin Clark-Casey (justincc) 8cd7ca568d Change default script stop method to co-op instead of abort.
co-op should be more stable as it doesn't abort threads, which can trigger virtual machine instability
This change will be invisible to users as script DLLs are recompiled automatically where necessary, though the change won't take affect until the next simulator restart.
This change has no effect on existing script state.
If you want to continue using abort, set ScriptStopStrategy = abort in the [XEngine] section of OpenSim.ini
2014-07-16 22:58:38 +01:00
Justin Clark-Casey (justincc) 2766bf3fef minor: Move debug xengine script console command to Debug help section where other debug commands live. 2014-07-11 00:18:39 +01:00
Justin Clark-Casey (justincc) 15b38f0036 minor: further cleanup of old vb and yield prolog script engine references that were removed some time ago 2014-07-11 00:15:47 +01:00
Justin Clark-Casey (justincc) d7b9260496 If [XEngine] ScriptStopStrategy is changed between abort and co-op, for the existing session use the previous strategy for that script rather than not starting the script at all.
We have to do this since we can't unload existing DLLs if they're all in the same AppDomain.
But we can still update the underlying DLL which will be used in the next simulator session.
2014-07-11 00:03:02 +01:00
Eva Comaroski 63ccc3dbf5 Convert if-blocks to return statements in small functions such as GetStartParameter(). 2013-12-14 01:20:24 +00:00
Justin Clark-Casey (justincc) 206fb306a7 Update SmartThreadPool to latest version 2.2.3 with a major and minor change.
SmartThreadPool code comes from http://www.codeproject.com/Articles/7933/Smart-Thread-Pool
This version implements thread abort (via WorkItem.Cancel(true)), threadpool naming, max thread stack, etc. so we no longer need to manually patch those.
However, two changes have been made to stock 2.2.3.
Major change: WorkItem.Cancel(bool abortExecution) in our version does not succeed if the work item was in progress and thread abort was not specified.
This is to match previous behaviour where we handle co-operative termination via another mechanism rather than checking WorkItem.IsCanceled.
Minor change: Did not add STP's StopWatch implementation as this is only used WinCE and Silverlight and causes a build clash with System.Diagnostics.StopWatch
The reason for updating is to see if this improves http://opensimulator.org/mantis/view.php?id=6557 and http://opensimulator.org/mantis/view.php?id=6586
2013-05-01 19:01:43 +01:00
Justin Clark-Casey (justincc) 2bfe60e2fb Use Output instead of OutputFormat in appropriate places of XEngine status reporting. 2013-04-02 01:28:16 +01:00
Justin Clark-Casey (justincc) ca26ff9436 minor: remove some mono compile warnings in XEngine.cs 2013-01-29 03:58:11 +00:00
Justin Clark-Casey (justincc) 55c6753b13 Merge branch 'master' into cooptermination 2013-01-24 00:03:44 +00:00
Justin Clark-Casey (justincc) 72dd3633ee Improve logging by making it clearer which script is failing if an assembly fails to load.
Moves the noise co-op start/stop debug log messages to only display if xengine debug level >= 1
Logs which stop strategy is being used (abort or co-op)
Adjusts some other logging to remove not very useful stuff
2013-01-23 23:34:15 +00:00
Justin Clark-Casey (justincc) cf168194e5 If ScriptStopStrategy hasn't been set to co-op in [XEngine] config, then continue to generate C# that is functionality identical to historical generation
This is to eliminate disruption until co-op termination has been well-tested.
In non co-op mode, XEngine will continue to load DLLs of the existing Script class and the new XEngineScript class.
Moving to co-op mode still requires existing script DLL deletion to force recompilation, either manually or by setting DeleteScriptsOnStartup = true for one run.
This change also means that scripts which fail to initialize do not still show up as running scripts.
2013-01-23 02:36:43 +00:00
Justin Clark-Casey (justincc) 1730de14a4 minor: comment out Console.WriteLine debugging message in XEngine 2013-01-22 01:00:53 +00:00
Oren Hurvitz b77da5039e Assign the SmartThreadPool name in the constructor
This is required because some threads are created in the constructor, so assigning the name afterwards would be too late.
2013-01-19 02:08:58 +00:00
Justin Clark-Casey (justincc) c8afc8523b Implement non-wait co-operative termination of scripts for XEngine in addition to termination on wait.
This involves inserting opensim_reserved_CheckForCoopTermination() calls in lsl -> c# translation at any place where the script could be in a loop with no wait calls.
These places are for, while, do-while, label, user function call and manual event function call.
Call goes through to an XEngineScriptBase which extends ScriptBase.
IEngine is extended to supply necessary engine-specific parent class references and constructor parameters to Compiler.
Unfortunately, since XEngineScriptBase has to be passed WaitHandle in its constructor, older compiled scripts will fail to load with an error on the OpenSim console.
Such scripts will need to be recompiled, either by removing all *.dll files from the bin/ScriptEngines/<region-id> or by setting DeleteScriptsOnStartup = true in [XEngine] for one run.
Automatic recompilation may be implemented in a later commit.
This feature should not yet be used, default remains termination with Thread.Abort() which will work as normal once scripts are recompiled.
2013-01-17 23:39:09 +00:00
Justin Clark-Casey (justincc) 0963ece25b Implement co-operative script termination if termination comes during a script wait event (llSleep(), etc.)
This makes use of EventWaitHandles since various web references indicate that Thread.Interrupt() can also cause runtime instability.
If co-op termination is enabled, then termination sets the wait handle instead of waiting for a timeout before possibly aborting the thread.
This allows the script to cleanly terminate if it's in a llSleep/LL function delay or the next time it enters such a wait without any timeout period.
Co-op termination is not yet testable since checking for termination request within loops that never trigger a wait is not yet implemented.
This commit, unlike 1b5c41c, passes the wait handle as an extra parameter through IScript.Initialize() instead of passing IScriptInstance itself.
2013-01-16 02:07:43 +00:00
Justin Clark-Casey (justincc) b8949024bc Revert "Implement co-operative script termination if termination comes during a script wait event (llSleep(), etc.)"
Doing this as a favour to Melanie.  This will be back with passing the wait handles directly to the api.

This reverts commit 1b5c41c14a.
2013-01-16 01:45:09 +00:00
Justin Clark-Casey (justincc) 1b5c41c14a Implement co-operative script termination if termination comes during a script wait event (llSleep(), etc.)
This makes use of EventWaitHandles since various web references indicate that Thread.Interrupt() can also cause runtime instability.
If co-op termination is enabled, then termination sets the wait handle instead of waiting for a timeout before possibly aborting the thread.
This allows the script to cleanly terminate if it's in a llSleep/LL function delay or the next time it enters such a wait without any timeout period.
Co-op termination is not yet testable since checking for termination request within loops that never trigger a wait is not yet implemented.
2013-01-16 00:12:40 +00:00
Justin Clark-Casey (justincc) fccb03227e Instead of passing separate engine, part and item components to script APIs, pass down IScriptInstance instead.
This is to allow the future co-operative script thread terminate feature to detect and act upon termination requests.
This splits the assembly and state loading out from the ScriptInstance() constructor to a separate Load() method
in order to facilititate continued script logic regression testing.
2013-01-15 21:13:22 +00:00
Justin Clark-Casey (justincc) a0000a034f Add "show sensors" command to show script sensor information for debug purposes. 2013-01-10 00:32:22 +00:00
Justin Clark-Casey (justincc) 3d5e3e35b7 minor: Fix command match of "debug script" command to "debug scripts" to match other scripts commands (and it's own short help text) 2013-01-09 00:08:08 +00:00
Justin Clark-Casey (justincc) 5fa4b8b144 minor: Allow "script *" console commands to take multiple script item ids 2013-01-09 00:01:48 +00:00
Justin Clark-Casey (justincc) bc9a7ba0d6 minor: Assign names to the different SmartThreadPools for debugging purposes.
A different approach to the patch in http://opensimulator.org/mantis/view.php?id=6462
that doesn't involve further forking of SmartThreadPool
2013-01-01 23:57:20 +00:00
Justin Clark-Casey (justincc) e6fd8365af Extend default 1 second wait for event completion to other thread script reset (as called by llResetOtherScript()).
As with script stop (via llDie()) aborting other scripts event threads, llResetOtherScript() can also abort any current event thread on another script.
On mono 2.6, 2.10 and possibly later this may cause locking problems in certain code areas.
This commit reuses the recently introduced [XEngine] WaitForEventCompletionOnScriptStop to make this a 1 sec timeout, rather than 0 secs.
2012-12-17 21:37:02 +00:00
Justin Clark-Casey (justincc) 523213060b Add WaitForEventCompletionOnScriptStop [XEngine] config param to OpenSimDefaults.ini to allow change of the wait time for an event to complete on script removal before aborting its thread
Default is 1000, as has previously been the case.
This parameter exists for further debug work concerning mono 2.10 crashes that may be related to locks not being removed on Thread.Abort
2012-12-13 23:21:25 +00:00
Justin Clark-Casey (justincc) 047270bdc8 Add "debug script log" command to allow setting a numeric debug level on individual IScriptInstances for debugging purposes.
Current, state changes and event fires can be logged for individual scripts.
See command help for more details.
2012-12-12 23:13:34 +00:00
Justin Clark-Casey (justincc) 418c0cb01d Add asset id to "show script" and "show scripts" command output to make it easier to extract and inspect the script's asset via "dump asset" 2012-12-12 22:06:09 +00:00
Justin Clark-Casey (justincc) ec765de7e5 Add engine-wide events queued and events processed numbers to output of "xengine status" console command. For debugging purposes. 2012-12-05 23:41:50 +00:00
Justin Clark-Casey (justincc) 5ba99cbf55 Add IScriptInstance.EventsQueued to match EventsProcessed instead of asking callers to lock and directly inspect the EventQueue 2012-12-05 23:33:48 +00:00
Justin Clark-Casey (justincc) 652f4bcb42 For now, sort "show scripts" output in descending order sorted by events processed.
For debug purposes - should later add options to allow different sorting or show only highest 10, etc.
2012-12-05 23:27:50 +00:00
Justin Clark-Casey (justincc) e8df0f1b4c Add IScriptInstance.EventsProcessed stat so that we can record this information and display in "show scripts" for debug purposes 2012-12-05 22:33:46 +00:00
Justin Clark-Casey (justincc) ea786414c2 In XEngine.DoOnRezScript() use Culture.SetCurrentCulture() instead of constructing a new CultureInfo separately 2012-12-05 21:51:08 +00:00
Justin Clark-Casey (justincc) d97440c7cf On XEngine.ProcessEventHandler(), instead of creating a new CultureInfo on every call use the single one set by Culture.SetCurrentCulture()
This is slightly different in that SetCurrentCulture() does not use overridden settings if the system culture matches en-US but some settings there have been changed.
This is what we want - we do not want to use any system overriden settings.
2012-12-05 21:40:28 +00:00
Justin Clark-Casey (justincc) f3a5e3a02b Log initial script startup info notice when xengine actually starts to do this for debugging purposes, rather than before it actually starts to do this. 2012-08-25 00:42:32 +01:00
Justin Clark-Casey (justincc) aede42b875 If a script state save fails for some reason on shutdown/region removal, get xengine to spit out some useful information and continue to save other script states 2012-08-23 23:13:53 +01:00