Commit Graph

42 Commits (741caee04017afdef55fdf08dcc651f44f1b4782)

Author SHA1 Message Date
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
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) 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) a82bd5678e Use an integer when specifying the XWorkItem wait rather than a TimeSpan to avoid a Windows casting issue in SmartThreadPool for large TimeSpans.
TimeSpan.Milliseconds is an int64.  However, STP casts this to an int (32-bit).
If TimeSpan.MaxValue is given then the casting results in an invalid value for the SDK WaitHandle.WaitAll() call.
This was causing the co-op script termination regression tests to fail on Windows but not Mono 2.10.8 (which is perhaps not strict in the negative values that it accepts).
Solution here is to use the int millisecondsTimeout STP call rather than the TimeSpan one.
This also allows us to more clearly specify Timeout.Infinite rather than TimeSpan.MaxValue
Thanks to Teravus for this spot.
2013-02-12 21:34:12 +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) 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) 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) 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) 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
Melanie 1c3b0da74a Revert "Fix script "Running" behavior"
A better solution using the already present flags must be found.

This reverts commit 6d3ee8bb39.
2012-07-16 23:31:55 +01:00
BlueWall 6d3ee8bb39 Fix script "Running" behavior
Unchecking "Running" box in script editor now persists. This fixes http://opensimulator.org/mantis/view.php?id=6057
2012-06-23 04:15:14 -04:00
Justin Clark-Casey (justincc) c386b68373 Aggregate script execution times by linksets rather than individual prims.
This is for the top scripts report.
2012-03-16 01:31:53 +00:00
Justin Clark-Casey (justincc) a4b01ef38a Replace script-lines-per-second with the script execution time scaled by its measurement period and an idealised frame time.
The previous lines-per-second measurement used for top scripts report was inaccurate, since lines executed does not reflect time taken to execute.
Also, every fetch of the report would reset all the numbers limiting its usefulness and we weren't even guaranteed to see the top 100.
The actual measurement value should be script execution time per frame but XEngine does not work this way.
Therefore, we use actual script execution time scaled by the measurement period and an idealised frame time.
This is still not ideal but gives reasonable results and allows scripts to be compared.
This commit moves script execution time calculations from SceneGraph into IScriptModule implementations.
2012-03-16 00:34:30 +00:00
Justin Clark-Casey (justincc) acb1355ff2 Remove property/field duplication in ScriptInstance where it's unnecessary. 2012-03-15 02:02:31 +00:00
Justin Clark-Casey (justincc) 95ec96bf86 refactor: rename ScriptInstance.m_CurrentResult to m_CurrentWorkItem to make it more understandable as to what it is and what it does (hold a thread pool work item for a waiting of in-progress event)
Also add other various illustrative comments
2012-03-14 00:29:36 +00:00
Justin Clark-Casey (justincc) 116fbe8258 add current script status to "scripts show" command (running, suspended, etc.) 2011-10-19 20:24:07 +01:00
Justin Clark-Casey (justincc) cf3ffe5bb4 Fix llAttachToAvatar()
Apart from one obvious bug, this was failing because attempting to serialize the script from inside the script (as part of saving the attachment as an inventory asset) was triggering an extremely long delay.
So we now don't do this.  The state will be serialized anyway when the avatar normally logs out.
The worst that can happen is that if the client/server crashes, the attachment scripts start without previous state.
2011-08-24 20:49:23 +01:00
Marck 2827deffe8 Trigger changed event with CHANGED_TELEPORT when teleporting to another region. 2010-11-26 22:46:48 +01:00
Melanie c1ad8a3c17 People can't leave their hands ooff "well enough". StateSource 0 was region
start, and they started at 1 for real values. Whoever changed that enum
to start at 0 should bow their head in shame. They broke the region start
event. This puts it right again. Meow!
2010-08-06 15:05:35 +01:00
Melanie 21cad5d3ac All scripts are now created suspended and are only unsuspended when the object
is fully rezzed and all scripts in it are instantiated. This ensures that link
messages will not be lost on rez/region crossing and makes heavily scripted
objects reliable.
2010-04-19 06:29:26 +01:00
Melanie 9d63f90467 Remove the old (Remoting) region crossing code. Fix the new code to
pass script state and assembly again properly. Reintroduce respecting tht
TrustBinaries flag. Changes the interregion protocol! No version bump
because it was broken anyway, so with a version mismatch it will simply
stay broken, but not crash. Region corssing still doesn't work because
there is still monkey business with both rezzed prims being pushed across
a border and attached prims when walking across a border. Teleport is
untested by may work.
2009-11-26 17:03:09 +00:00
Alan Webb 068f54725b Slight change to state management for attach scheduling.
Signed-off-by: dr scofield (aka dirk husemann) <drscofield@xyzzyxyzzy.net>
2009-08-04 11:44:22 +02:00
Melanie 17bdc45c5c Add plumbing for the SceneObjectDeleter to wait for the script engine to
allow final deletion of objects. Meant to support the attach(NULL_KEY) event,
2009-08-04 03:17:13 +01:00
Jeff Ames 840de6c036 Minor: Change OpenSim to OpenSimulator in older copyright headers and LICENSE.txt. 2009-06-01 06:37:14 +00:00
Melanie Thielker 3c338e4e56 Convert both script engines to new region module format. Add proper unload
handling to XEngine. Add needed stubs to DotNetEngine.
2009-04-15 18:51:17 +00:00
Dr Scofield ce1e1854b1 From: Christopher Yeoh <yeohc@au1.ibm.com>
This changeset fixes a race condition where a script (XEngine run) can
startup before a reference is added to it in all of the required
places in the XEngine class. The effect of this is that a script can
sometimes on startup miss script events. For example a script which
starts up and initialises itself from a notecard may never receive the
dataserver event containing the notecard information.

The patch isn't as clean as I'd like - I've split the constructor of
ScriptInstance up so it does everything it did before except
call Startup and post events like state_entry and on_rez. An Init
function has been added which is called after the ScriptInstance
object has been added to the necessary data structures in XEngine.

Happy to rework it if someone suggests a better way of doing it.
2009-01-28 09:52:09 +00:00
idb 3fe966d6b3 An initial implementation of llMinEventDelay in XEngine.
Not implemented yet in DotNetEngine.
Fixes Mantis #2830
2008-12-21 19:04:06 +00:00
Melanie Thielker af5e9147f0 Start scripts in attachments only after a successful attach. Elimininate
a gratuitious asset fetch when region crossing.
2008-11-29 14:16:09 +00:00
Melanie Thielker ca35b49b70 Make scripts in objects rezzed from script compile synchronously to close
a timing gap. Still not 100%, but getting there
2008-11-13 19:00:46 +00:00
Melanie Thielker 664e8a464e Script region crossing. This has not user functionality, but lays all the
groundwork.
2008-11-09 19:30:40 +00:00
Melanie Thielker 833f5e8bed Refactor IEventReceiver back into IScriptEngine 2008-11-08 02:24:34 +00:00
Melanie Thielker 85068dae60 Add friendly error messages to both engines. 2008-09-27 05:31:43 +00:00
Melanie Thielker 7e8320bada Kan-Ed fix series. Fix llTakeControls to behave as documented.
XEngine fixes: prevent queue overruns, prevent spamming when no key
is down. Release controls when conflicting permissions are requested
or permissions are refused later. Release when prim or script are deleted.
Fixes Scene script instance deletion semantics.
2008-09-17 22:00:56 +00:00
Justin Clarke Casey 7f3bfa277b * minor: method documentation 2008-09-16 16:37:16 +00:00
Melanie Thielker fdb24c46ac Provide a GetApi method on the IScriptEngine to get a named API reference
This allows cross-api method calls on the implementation and also allows
"Meta APIs" that only provide common functionality to other APIs
2008-09-13 14:40:42 +00:00
Melanie Thielker 490ac0be00 Implement proper persistence of the following prim properties:
Floating text, Rotation, Texture animation, Particle System
This will make "Eye Candy" scripts work without modification in
XEngine. The use of the CHANGED_REGION_RESTART hack is no longer
needed. Implemented in MySQL only, hovertext also in SQLite.
2008-09-08 02:40:20 +00:00
Teravus Ovares 7d89e12293 * This is the fabled LibOMV update with all of the libOMV types from JHurliman
* This is a HUGE OMG update and will definitely have unknown side effects.. so this is really only for the strong hearted at this point.  Regular people should let the dust settle.
* This has been tested to work with most basic functions. However..   make sure you back up 'everything' before using this.  It's that big!  
* Essentially we're back at square 1 in the testing phase..  so lets identify things that broke.
2008-09-06 07:52:41 +00:00
Melanie Thielker bf4d1fbb8d Refactor IScriptInstance / IScriptEngine to use a generic IScriptWorkItem,
which is a thin wrapper around a IWorkItemResult from the SmartThreadPool.
However, it is very easy to reimplement on top of basic threading and therefore
makes the IScriptInstance class independent of the specific threading
implementation.
2008-08-28 00:37:22 +00:00
Melanie Thielker 6e3367d68c Refactor XScriptInstance to IScriptInstance and move into Shared/. Now
engines that want to use the XEngine's instance handling and state
persistence can do so. IScriptInstance is optional, but it does
require the SmartThreadPool if it is used.
2008-08-27 22:38:36 +00:00