diff options
Diffstat (limited to 'OpenSim/Region/ScriptEngine/DotNetEngine')
-rw-r--r-- | OpenSim/Region/ScriptEngine/DotNetEngine/AppDomainManager.cs | 39 | ||||
-rw-r--r-- | OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs | 30 |
2 files changed, 36 insertions, 33 deletions
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/AppDomainManager.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/AppDomainManager.cs index 33e95d3..77c859f 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/AppDomainManager.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/AppDomainManager.cs | |||
@@ -5,6 +5,10 @@ using System.Reflection; | |||
5 | using System.Threading; | 5 | using System.Threading; |
6 | using System.Runtime.Remoting; | 6 | using System.Runtime.Remoting; |
7 | using System.IO; | 7 | using System.IO; |
8 | using OpenSim.Region.Environment.Scenes; | ||
9 | using OpenSim.Region.Environment.Scenes.Scripting; | ||
10 | using OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL; | ||
11 | using OpenSim.Region.ScriptEngine.Common; | ||
8 | 12 | ||
9 | namespace OpenSim.Region.ScriptEngine.DotNetEngine | 13 | namespace OpenSim.Region.ScriptEngine.DotNetEngine |
10 | { | 14 | { |
@@ -51,7 +55,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine | |||
51 | /// Find a free AppDomain, creating one if necessary | 55 | /// Find a free AppDomain, creating one if necessary |
52 | /// </summary> | 56 | /// </summary> |
53 | /// <returns>Free AppDomain</returns> | 57 | /// <returns>Free AppDomain</returns> |
54 | internal AppDomain GetFreeAppDomain() | 58 | private AppDomainStructure GetFreeAppDomain() |
55 | { | 59 | { |
56 | FreeAppDomains(); | 60 | FreeAppDomains(); |
57 | lock(GetLock) { | 61 | lock(GetLock) { |
@@ -78,9 +82,9 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine | |||
78 | // - We assume that every time someone wants an AppDomain they will load into it | 82 | // - We assume that every time someone wants an AppDomain they will load into it |
79 | // if this assumption is wrong we end up with a miscount and will never unload it. | 83 | // if this assumption is wrong we end up with a miscount and will never unload it. |
80 | // | 84 | // |
81 | CurrentAD.ScriptsLoaded++; | 85 | |
82 | // Return AppDomain | 86 | // Return AppDomain |
83 | return CurrentAD.CurrentAppDomain; | 87 | return CurrentAD; |
84 | } // lock | 88 | } // lock |
85 | } | 89 | } |
86 | 90 | ||
@@ -136,13 +140,37 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine | |||
136 | } // foreach | 140 | } // foreach |
137 | } // lock | 141 | } // lock |
138 | } | 142 | } |
143 | |||
144 | |||
145 | |||
146 | public OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL.LSL_BaseClass LoadScript(string FileName, IScriptHost host) | ||
147 | { | ||
148 | //LSL_BaseClass mbrt = (LSL_BaseClass)FreeAppDomain.CreateInstanceAndUnwrap(FileName, "SecondLife.Script"); | ||
149 | //Console.WriteLine("Base directory: " + AppDomain.CurrentDomain.BaseDirectory); | ||
150 | // * Find next available AppDomain to put it in | ||
151 | AppDomainStructure FreeAppDomain = GetFreeAppDomain(); | ||
152 | |||
153 | |||
154 | LSL_BaseClass mbrt = (LSL_BaseClass)FreeAppDomain.CurrentAppDomain.CreateInstanceFromAndUnwrap(FileName, "SecondLife.Script"); | ||
155 | //LSL_BuiltIn_Commands_Interface mbrt = (LSL_BuiltIn_Commands_Interface)FreeAppDomain.CreateInstanceFromAndUnwrap(FileName, "SecondLife.Script"); | ||
156 | //Type mytype = mbrt.GetType(); | ||
157 | //Console.WriteLine("is proxy={0}", RemotingServices.IsTransparentProxy(mbrt)); | ||
158 | |||
159 | FreeAppDomain.ScriptsLoaded++; | ||
160 | |||
161 | //mbrt.Start(); | ||
162 | return mbrt; | ||
163 | //return (LSL_BaseClass)mbrt; | ||
164 | |||
165 | } | ||
166 | |||
139 | 167 | ||
140 | /// <summary> | 168 | /// <summary> |
141 | /// Increase "dead script" counter for an AppDomain | 169 | /// Increase "dead script" counter for an AppDomain |
142 | /// </summary> | 170 | /// </summary> |
143 | /// <param name="ad"></param> | 171 | /// <param name="ad"></param> |
144 | [Obsolete("Needs optimizing!!!")] | 172 | [Obsolete("Needs fixing!!!")] |
145 | public void StopScriptInAppDomain(AppDomain ad) | 173 | public void StopScript(AppDomain ad) |
146 | { | 174 | { |
147 | lock (FreeLock) | 175 | lock (FreeLock) |
148 | { | 176 | { |
@@ -170,5 +198,6 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine | |||
170 | } // lock | 198 | } // lock |
171 | } | 199 | } |
172 | 200 | ||
201 | |||
173 | } | 202 | } |
174 | } | 203 | } |
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs index 926ec74..9a65b5c 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs | |||
@@ -172,15 +172,12 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine | |||
172 | // * Insert yield into code | 172 | // * Insert yield into code |
173 | FileName = ProcessYield(FileName); | 173 | FileName = ProcessYield(FileName); |
174 | 174 | ||
175 | // * Find next available AppDomain to put it in | ||
176 | AppDomain FreeAppDomain = m_scriptEngine.myAppDomainManager.GetFreeAppDomain(); | ||
177 | 175 | ||
178 | // * Load and start script, for now with dummy host | ||
179 | |||
180 | //OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSO.LSL_BaseClass Script = LoadAndInitAssembly(FreeAppDomain, FileName); | 176 | //OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSO.LSL_BaseClass Script = LoadAndInitAssembly(FreeAppDomain, FileName); |
181 | 177 | ||
182 | //OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL.LSL_BaseClass Script = LoadAndInitAssembly(FreeAppDomain, FileName, ObjectID); | 178 | //OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL.LSL_BaseClass Script = LoadAndInitAssembly(FreeAppDomain, FileName, ObjectID); |
183 | OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL.LSL_BaseClass Script = LoadAndInitAssembly(FreeAppDomain, FileName, ObjectID); | 179 | OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL.LSL_BaseClass Script = m_scriptEngine.myAppDomainManager.LoadScript(FileName, ObjectID); |
180 | |||
184 | 181 | ||
185 | // Add it to our temporary active script keeper | 182 | // Add it to our temporary active script keeper |
186 | //Scripts.Add(FullScriptID, Script); | 183 | //Scripts.Add(FullScriptID, Script); |
@@ -207,30 +204,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine | |||
207 | return FileName; | 204 | return FileName; |
208 | } | 205 | } |
209 | 206 | ||
210 | /// <summary> | ||
211 | /// Does actual loading and initialization of script Assembly | ||
212 | /// </summary> | ||
213 | /// <param name="FreeAppDomain">AppDomain to load script into</param> | ||
214 | /// <param name="FileName">FileName of script assembly (.dll)</param> | ||
215 | /// <returns></returns> | ||
216 | private OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL.LSL_BaseClass LoadAndInitAssembly(AppDomain FreeAppDomain, string FileName, IScriptHost host) | ||
217 | { | ||
218 | |||
219 | //LSL_BaseClass mbrt = (LSL_BaseClass)FreeAppDomain.CreateInstanceAndUnwrap(FileName, "SecondLife.Script"); | ||
220 | //Console.WriteLine("Base directory: " + AppDomain.CurrentDomain.BaseDirectory); | ||
221 | 207 | ||
222 | LSL_BaseClass mbrt = (LSL_BaseClass)FreeAppDomain.CreateInstanceFromAndUnwrap(FileName, "SecondLife.Script"); | ||
223 | //LSL_BuiltIn_Commands_Interface mbrt = (LSL_BuiltIn_Commands_Interface)FreeAppDomain.CreateInstanceFromAndUnwrap(FileName, "SecondLife.Script"); | ||
224 | Type mytype = mbrt.GetType(); | ||
225 | |||
226 | Console.WriteLine("is proxy={0}", RemotingServices.IsTransparentProxy(mbrt)); | ||
227 | |||
228 | |||
229 | //mbrt.Start(); | ||
230 | return mbrt; | ||
231 | //return (LSL_BaseClass)mbrt; | ||
232 | |||
233 | } | ||
234 | 208 | ||
235 | /// <summary> | 209 | /// <summary> |
236 | /// Execute a LL-event-function in Script | 210 | /// Execute a LL-event-function in Script |