diff options
author | Melanie Thielker | 2017-01-07 00:25:59 +0000 |
---|---|---|
committer | Melanie Thielker | 2017-01-07 00:25:59 +0000 |
commit | d9dba512237df704ddc8dfefbe206f0dd09a8232 (patch) | |
tree | a93756441f08cb6fd986e40da4e4385ea2f3324a | |
parent | Fix a slew of event like CHANGED_OWNER, attach() etc not working. (diff) | |
download | opensim-SC-d9dba512237df704ddc8dfefbe206f0dd09a8232.zip opensim-SC-d9dba512237df704ddc8dfefbe206f0dd09a8232.tar.gz opensim-SC-d9dba512237df704ddc8dfefbe206f0dd09a8232.tar.bz2 opensim-SC-d9dba512237df704ddc8dfefbe206f0dd09a8232.tar.xz |
Queue all events for a script that is waiting to compile
This fixes CHANGED_OWNER the right way. It also vastly improves link
message handling during object rez, which was iffy before. Now no
messages are lost anymore.
-rwxr-xr-x | OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | 69 |
1 files changed, 56 insertions, 13 deletions
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index e3922d6..dbc38a7 100755 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | |||
@@ -182,7 +182,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
182 | 182 | ||
183 | private ScriptCompileQueue m_CompileQueue = new ScriptCompileQueue(); | 183 | private ScriptCompileQueue m_CompileQueue = new ScriptCompileQueue(); |
184 | IWorkItemResult m_CurrentCompile = null; | 184 | IWorkItemResult m_CurrentCompile = null; |
185 | private Dictionary<UUID, int> m_CompileDict = new Dictionary<UUID, int>(); | 185 | private Dictionary<UUID, ScriptCompileInfo> m_CompileDict = new Dictionary<UUID, ScriptCompileInfo>(); |
186 | 186 | ||
187 | private ScriptEngineConsoleCommands m_consoleCommands; | 187 | private ScriptEngineConsoleCommands m_consoleCommands; |
188 | 188 | ||
@@ -236,6 +236,11 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
236 | get { return m_ConfigSource; } | 236 | get { return m_ConfigSource; } |
237 | } | 237 | } |
238 | 238 | ||
239 | private class ScriptCompileInfo | ||
240 | { | ||
241 | public List<EventParams> eventList = new List<EventParams>(); | ||
242 | } | ||
243 | |||
239 | /// <summary> | 244 | /// <summary> |
240 | /// Event fired after the script engine has finished removing a script. | 245 | /// Event fired after the script engine has finished removing a script. |
241 | /// </summary> | 246 | /// </summary> |
@@ -1005,18 +1010,12 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1005 | 1010 | ||
1006 | Object[] parms = new Object[]{localID, itemID, script, startParam, postOnRez, (StateSource)stateSource}; | 1011 | Object[] parms = new Object[]{localID, itemID, script, startParam, postOnRez, (StateSource)stateSource}; |
1007 | 1012 | ||
1008 | // There IS such a thing as too much optimization!! | 1013 | if (stateSource == (int)StateSource.ScriptedRez) |
1009 | // DON'T try to defer and queue the below states! | ||
1010 | // Doing so may make rezzing snappier in world, but prevents | ||
1011 | // vital events like attach, changed owner, etc, from firing. | ||
1012 | // This just MUST be synchronous. Believe me, I'm The Author! | ||
1013 | if (stateSource == (int)StateSource.ScriptedRez || | ||
1014 | stateSource == (int)StateSource.NewRez || | ||
1015 | stateSource == (int)StateSource.AttachedRez) | ||
1016 | { | 1014 | { |
1017 | lock (m_CompileDict) | 1015 | lock (m_CompileDict) |
1018 | { | 1016 | { |
1019 | m_CompileDict[itemID] = 0; | 1017 | m_log.DebugFormat("[XENGINE]: Set compile dict for {0}", itemID); |
1018 | m_CompileDict[itemID] = new ScriptCompileInfo(); | ||
1020 | } | 1019 | } |
1021 | 1020 | ||
1022 | DoOnRezScript(parms); | 1021 | DoOnRezScript(parms); |
@@ -1024,7 +1023,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1024 | else | 1023 | else |
1025 | { | 1024 | { |
1026 | lock (m_CompileDict) | 1025 | lock (m_CompileDict) |
1027 | m_CompileDict[itemID] = 0; | 1026 | m_CompileDict[itemID] = new ScriptCompileInfo(); |
1027 | m_log.DebugFormat("[XENGINE]: Set compile dict for {0} delayed", itemID); | ||
1028 | 1028 | ||
1029 | // This must occur after the m_CompileDict so that an existing compile thread cannot hit the check | 1029 | // This must occur after the m_CompileDict so that an existing compile thread cannot hit the check |
1030 | // in DoOnRezScript() before m_CompileDict has been updated. | 1030 | // in DoOnRezScript() before m_CompileDict has been updated. |
@@ -1142,7 +1142,6 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1142 | { | 1142 | { |
1143 | if (!m_CompileDict.ContainsKey(itemID)) | 1143 | if (!m_CompileDict.ContainsKey(itemID)) |
1144 | return false; | 1144 | return false; |
1145 | m_CompileDict.Remove(itemID); | ||
1146 | } | 1145 | } |
1147 | 1146 | ||
1148 | // Get the asset ID of the script, so we can check if we | 1147 | // Get the asset ID of the script, so we can check if we |
@@ -1157,6 +1156,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1157 | m_log.ErrorFormat("[Script]: SceneObjectPart with localID {0} unavailable. Script NOT started.", localID); | 1156 | m_log.ErrorFormat("[Script]: SceneObjectPart with localID {0} unavailable. Script NOT started.", localID); |
1158 | m_ScriptErrorMessage += "SceneObjectPart unavailable. Script NOT started.\n"; | 1157 | m_ScriptErrorMessage += "SceneObjectPart unavailable. Script NOT started.\n"; |
1159 | m_ScriptFailCount++; | 1158 | m_ScriptFailCount++; |
1159 | lock (m_CompileDict) | ||
1160 | m_CompileDict.Remove(itemID); | ||
1160 | return false; | 1161 | return false; |
1161 | } | 1162 | } |
1162 | 1163 | ||
@@ -1165,6 +1166,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1165 | { | 1166 | { |
1166 | m_ScriptErrorMessage += "Can't find script inventory item.\n"; | 1167 | m_ScriptErrorMessage += "Can't find script inventory item.\n"; |
1167 | m_ScriptFailCount++; | 1168 | m_ScriptFailCount++; |
1169 | lock (m_CompileDict) | ||
1170 | m_CompileDict.Remove(itemID); | ||
1168 | return false; | 1171 | return false; |
1169 | } | 1172 | } |
1170 | 1173 | ||
@@ -1282,6 +1285,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1282 | // e.Message.ToString()); | 1285 | // e.Message.ToString()); |
1283 | // } | 1286 | // } |
1284 | 1287 | ||
1288 | lock (m_CompileDict) | ||
1289 | m_CompileDict.Remove(itemID); | ||
1285 | return false; | 1290 | return false; |
1286 | } | 1291 | } |
1287 | } | 1292 | } |
@@ -1352,6 +1357,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1352 | { | 1357 | { |
1353 | m_AddingAssemblies[assemblyPath]--; | 1358 | m_AddingAssemblies[assemblyPath]--; |
1354 | } | 1359 | } |
1360 | lock (m_CompileDict) | ||
1361 | m_CompileDict.Remove(itemID); | ||
1355 | return false; | 1362 | return false; |
1356 | } | 1363 | } |
1357 | } | 1364 | } |
@@ -1409,6 +1416,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1409 | assemblyName.FullName, World.Name), | 1416 | assemblyName.FullName, World.Name), |
1410 | e2); | 1417 | e2); |
1411 | 1418 | ||
1419 | lock (m_CompileDict) | ||
1420 | m_CompileDict.Remove(itemID); | ||
1412 | return false; | 1421 | return false; |
1413 | } | 1422 | } |
1414 | 1423 | ||
@@ -1458,6 +1467,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1458 | assemblyName.FullName, World.Name), | 1467 | assemblyName.FullName, World.Name), |
1459 | e2); | 1468 | e2); |
1460 | 1469 | ||
1470 | lock (m_CompileDict) | ||
1471 | m_CompileDict.Remove(itemID); | ||
1461 | return false; | 1472 | return false; |
1462 | } | 1473 | } |
1463 | 1474 | ||
@@ -1485,7 +1496,11 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1485 | 1496 | ||
1486 | if(!instance.Load(scriptObj, coopSleepHandle, assemblyPath, | 1497 | if(!instance.Load(scriptObj, coopSleepHandle, assemblyPath, |
1487 | Path.Combine(ScriptEnginePath, World.RegionInfo.RegionID.ToString()), stateSource, coopTerminationForThisScript)) | 1498 | Path.Combine(ScriptEnginePath, World.RegionInfo.RegionID.ToString()), stateSource, coopTerminationForThisScript)) |
1488 | return false; | 1499 | { |
1500 | lock (m_CompileDict) | ||
1501 | m_CompileDict.Remove(itemID); | ||
1502 | return false; | ||
1503 | } | ||
1489 | 1504 | ||
1490 | // if (DebugLevel >= 1) | 1505 | // if (DebugLevel >= 1) |
1491 | // m_log.DebugFormat( | 1506 | // m_log.DebugFormat( |
@@ -1525,7 +1540,16 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1525 | } | 1540 | } |
1526 | 1541 | ||
1527 | if (instance != null) | 1542 | if (instance != null) |
1543 | { | ||
1528 | instance.Init(); | 1544 | instance.Init(); |
1545 | lock (m_CompileDict) | ||
1546 | { | ||
1547 | foreach (EventParams pp in m_CompileDict[itemID].eventList) | ||
1548 | instance.PostEvent(pp); | ||
1549 | } | ||
1550 | } | ||
1551 | lock (m_CompileDict) | ||
1552 | m_CompileDict.Remove(itemID); | ||
1529 | 1553 | ||
1530 | bool runIt; | 1554 | bool runIt; |
1531 | if (m_runFlags.TryGetValue(itemID, out runIt)) | 1555 | if (m_runFlags.TryGetValue(itemID, out runIt)) |
@@ -1749,6 +1773,17 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1749 | instance.PostEvent(p); | 1773 | instance.PostEvent(p); |
1750 | result = true; | 1774 | result = true; |
1751 | } | 1775 | } |
1776 | else | ||
1777 | { | ||
1778 | lock (m_CompileDict) | ||
1779 | { | ||
1780 | if (m_CompileDict.ContainsKey(itemID)) | ||
1781 | { | ||
1782 | m_CompileDict[itemID].eventList.Add(p); | ||
1783 | result = true; | ||
1784 | } | ||
1785 | } | ||
1786 | } | ||
1752 | } | 1787 | } |
1753 | } | 1788 | } |
1754 | 1789 | ||
@@ -1770,6 +1805,14 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1770 | instance.PostEvent(p); | 1805 | instance.PostEvent(p); |
1771 | return true; | 1806 | return true; |
1772 | } | 1807 | } |
1808 | lock (m_CompileDict) | ||
1809 | { | ||
1810 | if (m_CompileDict.ContainsKey(itemID)) | ||
1811 | { | ||
1812 | m_CompileDict[itemID].eventList.Add(p); | ||
1813 | return true; | ||
1814 | } | ||
1815 | } | ||
1773 | return false; | 1816 | return false; |
1774 | } | 1817 | } |
1775 | 1818 | ||