diff options
author | UbitUmarov | 2018-03-09 21:33:39 +0000 |
---|---|---|
committer | UbitUmarov | 2018-03-09 21:33:39 +0000 |
commit | c723a1be16307850055a9644f705f63f74df0c39 (patch) | |
tree | d2384aa7ade0f77a3bff00b749dd99f9a23f007e /OpenSim/Region | |
parent | Merge branch 'master' into httptests (diff) | |
download | opensim-SC-c723a1be16307850055a9644f705f63f74df0c39.zip opensim-SC-c723a1be16307850055a9644f705f63f74df0c39.tar.gz opensim-SC-c723a1be16307850055a9644f705f63f74df0c39.tar.bz2 opensim-SC-c723a1be16307850055a9644f705f63f74df0c39.tar.xz |
Yengine temp file delete was still bad in case of script errors
Diffstat (limited to 'OpenSim/Region')
-rw-r--r-- | OpenSim/Region/ScriptEngine/YEngine/MMRScriptCodeGen.cs | 46 | ||||
-rw-r--r-- | OpenSim/Region/ScriptEngine/YEngine/MMRScriptCompile.cs | 33 | ||||
-rw-r--r-- | OpenSim/Region/ScriptEngine/YEngine/XMRInstRun.cs | 25 |
3 files changed, 53 insertions, 51 deletions
diff --git a/OpenSim/Region/ScriptEngine/YEngine/MMRScriptCodeGen.cs b/OpenSim/Region/ScriptEngine/YEngine/MMRScriptCodeGen.cs index 8131732..8bcb995 100644 --- a/OpenSim/Region/ScriptEngine/YEngine/MMRScriptCodeGen.cs +++ b/OpenSim/Region/ScriptEngine/YEngine/MMRScriptCodeGen.cs | |||
@@ -835,33 +835,41 @@ namespace OpenSim.Region.ScriptEngine.Yengine | |||
835 | // Do both global functions, script-defined class static methods and | 835 | // Do both global functions, script-defined class static methods and |
836 | // script-defined instance methods, as we handle the differences | 836 | // script-defined instance methods, as we handle the differences |
837 | // during compilation of the functions/methods themselves. | 837 | // during compilation of the functions/methods themselves. |
838 | for(int pass = 0; pass < 2; pass++) | 838 | |
839 | // headers | ||
840 | foreach(TokenDeclVar declFunc in tokenScript.variablesStack) | ||
839 | { | 841 | { |
840 | foreach(TokenDeclVar declFunc in tokenScript.variablesStack) | 842 | if(declFunc.retType != null) |
843 | GenerateMethodHeader(declFunc); | ||
844 | } | ||
845 | foreach(TokenDeclSDType sdType in tokenScript.sdSrcTypesValues) | ||
846 | { | ||
847 | if(sdType is TokenDeclSDTypeClass) | ||
841 | { | 848 | { |
842 | if(declFunc.retType != null) | 849 | TokenDeclSDTypeClass sdtClass = (TokenDeclSDTypeClass)sdType; |
850 | foreach(TokenDeclVar declFunc in sdtClass.members) | ||
843 | { | 851 | { |
844 | if(pass == 0) | 852 | if((declFunc.retType != null) && ((declFunc.sdtFlags & ScriptReduce.SDT_ABSTRACT) == 0)) |
845 | GenerateMethodHeader(declFunc); | 853 | GenerateMethodHeader(declFunc); |
846 | else | ||
847 | GenerateMethodBody(declFunc); | ||
848 | } | 854 | } |
849 | } | 855 | } |
850 | foreach(TokenDeclSDType sdType in tokenScript.sdSrcTypesValues) | 856 | } |
857 | |||
858 | // now bodies | ||
859 | foreach(TokenDeclVar declFunc in tokenScript.variablesStack) | ||
860 | { | ||
861 | if(declFunc.retType != null) | ||
862 | GenerateMethodBody(declFunc); | ||
863 | } | ||
864 | foreach(TokenDeclSDType sdType in tokenScript.sdSrcTypesValues) | ||
865 | { | ||
866 | if(sdType is TokenDeclSDTypeClass) | ||
851 | { | 867 | { |
852 | if(sdType is TokenDeclSDTypeClass) | 868 | TokenDeclSDTypeClass sdtClass = (TokenDeclSDTypeClass)sdType; |
869 | foreach(TokenDeclVar declFunc in sdtClass.members) | ||
853 | { | 870 | { |
854 | TokenDeclSDTypeClass sdtClass = (TokenDeclSDTypeClass)sdType; | 871 | if((declFunc.retType != null) && ((declFunc.sdtFlags & ScriptReduce.SDT_ABSTRACT) == 0)) |
855 | foreach(TokenDeclVar declFunc in sdtClass.members) | 872 | GenerateMethodBody(declFunc); |
856 | { | ||
857 | if((declFunc.retType != null) && ((declFunc.sdtFlags & ScriptReduce.SDT_ABSTRACT) == 0)) | ||
858 | { | ||
859 | if(pass == 0) | ||
860 | GenerateMethodHeader(declFunc); | ||
861 | else | ||
862 | GenerateMethodBody(declFunc); | ||
863 | } | ||
864 | } | ||
865 | } | 873 | } |
866 | } | 874 | } |
867 | } | 875 | } |
diff --git a/OpenSim/Region/ScriptEngine/YEngine/MMRScriptCompile.cs b/OpenSim/Region/ScriptEngine/YEngine/MMRScriptCompile.cs index d16ba47..f0ee361 100644 --- a/OpenSim/Region/ScriptEngine/YEngine/MMRScriptCompile.cs +++ b/OpenSim/Region/ScriptEngine/YEngine/MMRScriptCompile.cs | |||
@@ -90,46 +90,44 @@ namespace OpenSim.Region.ScriptEngine.Yengine | |||
90 | // Create object file one way or another. | 90 | // Create object file one way or another. |
91 | try | 91 | try |
92 | { | 92 | { |
93 | objFileStream = File.Create (tmpFileName); | ||
94 | |||
95 | // Create abstract syntax tree from raw tokens. | 93 | // Create abstract syntax tree from raw tokens. |
96 | TokenScript tokenScript = ScriptReduce.Reduce(tokenBegin); | 94 | TokenScript tokenScript = ScriptReduce.Reduce(tokenBegin); |
97 | if (tokenScript == null) | 95 | if (tokenScript == null) |
98 | { | 96 | { |
99 | m_log.Warn ("[YEngine]: reduction errors on " + m_ScriptObjCodeKey + " (" + m_CameFrom + ")"); | 97 | m_log.Warn ("[YEngine]: reduction errors on " + m_ScriptObjCodeKey + " (" + m_CameFrom + ")"); |
100 | PrintCompilerErrors(); | 98 | PrintCompilerErrors(); |
101 | objFileStream.Close(); | ||
102 | return null; | 99 | return null; |
103 | } | 100 | } |
104 | 101 | ||
105 | // Compile abstract syntax tree to write object file. | 102 | // Compile abstract syntax tree to write object file. |
106 | BinaryWriter objFileWriter = new BinaryWriter (objFileStream); | 103 | using(BinaryWriter objFileWriter = new BinaryWriter(File.Create(tmpFileName))) |
107 | bool ok = ScriptCodeGen.CodeGen(tokenScript, objFileWriter, sourceHash); | ||
108 | if (!ok) | ||
109 | { | 104 | { |
110 | m_log.Warn ("[YEngine]: compile error on " + m_ScriptObjCodeKey + " (" + m_CameFrom + ")"); | 105 | bool ok = ScriptCodeGen.CodeGen(tokenScript, objFileWriter, sourceHash); |
111 | PrintCompilerErrors (); | 106 | if (!ok) |
112 | objFileWriter.Close (); | 107 | { |
113 | return null; | 108 | m_log.Warn ("[YEngine]: compile error on " + m_ScriptObjCodeKey + " (" + m_CameFrom + ")"); |
109 | PrintCompilerErrors (); | ||
110 | return null; | ||
111 | } | ||
114 | } | 112 | } |
115 | objFileWriter.Close (); | ||
116 | 113 | ||
117 | // File has been completely written. | 114 | // File has been completely written. |
118 | // If there is an old one laying around, delete it now. | 115 | // If there is an old one laying around, delete it now. |
119 | // Then re-open the new file for reading from the beginning. | 116 | // Then re-open the new file for reading from the beginning. |
120 | if (File.Exists (objFileName)) | 117 | if (File.Exists(objFileName)) |
121 | File.Replace (tmpFileName, objFileName, null); | 118 | File.Replace(tmpFileName, objFileName, null); |
122 | else | 119 | else |
123 | File.Move (tmpFileName, objFileName); | 120 | File.Move(tmpFileName, objFileName); |
124 | 121 | ||
125 | objFileStream = File.OpenRead (objFileName); | 122 | objFileStream = File.OpenRead(objFileName); |
126 | } | 123 | } |
127 | finally | 124 | finally |
128 | { | 125 | { |
129 | // In case something went wrong writing temp file, delete it. | 126 | // In case something went wrong writing temp file, delete it. |
130 | try | 127 | try |
131 | { | 128 | { |
132 | File.Delete (tmpFileName); | 129 | if(File.Exists(tmpFileName)) |
130 | File.Delete (tmpFileName); | ||
133 | } | 131 | } |
134 | catch | 132 | catch |
135 | { | 133 | { |
@@ -169,7 +167,8 @@ namespace OpenSim.Region.ScriptEngine.Yengine | |||
169 | private void PrintCompilerErrors () | 167 | private void PrintCompilerErrors () |
170 | { | 168 | { |
171 | m_log.Info ("[YEngine]: - " + m_Part.GetWorldPosition () + " " + m_DescName); | 169 | m_log.Info ("[YEngine]: - " + m_Part.GetWorldPosition () + " " + m_DescName); |
172 | foreach (string error in m_CompilerErrors) { | 170 | foreach (string error in m_CompilerErrors) |
171 | { | ||
173 | m_log.Info ("[YEngine]: - " + error); | 172 | m_log.Info ("[YEngine]: - " + error); |
174 | } | 173 | } |
175 | } | 174 | } |
diff --git a/OpenSim/Region/ScriptEngine/YEngine/XMRInstRun.cs b/OpenSim/Region/ScriptEngine/YEngine/XMRInstRun.cs index 8ac9794..a52c4c8 100644 --- a/OpenSim/Region/ScriptEngine/YEngine/XMRInstRun.cs +++ b/OpenSim/Region/ScriptEngine/YEngine/XMRInstRun.cs | |||
@@ -399,8 +399,8 @@ namespace OpenSim.Region.ScriptEngine.Yengine | |||
399 | * Start event handler. | 399 | * Start event handler. |
400 | * | 400 | * |
401 | * Input: | 401 | * Input: |
402 | * eventCode = code of event to be processed | 402 | * newEventCode = code of event to be processed |
403 | * ehArgs = arguments for the event handler | 403 | * newEhArgs = arguments for the event handler |
404 | * | 404 | * |
405 | * Caution: | 405 | * Caution: |
406 | * It is up to the caller to make sure ehArgs[] is correct for | 406 | * It is up to the caller to make sure ehArgs[] is correct for |
@@ -409,15 +409,15 @@ namespace OpenSim.Region.ScriptEngine.Yengine | |||
409 | * from ehArgs[] and will throw an array bounds or cast exception | 409 | * from ehArgs[] and will throw an array bounds or cast exception |
410 | * if it can't. | 410 | * if it can't. |
411 | */ | 411 | */ |
412 | private Exception StartEventHandler(ScriptEventCode eventCode, object[] ehArgs) | 412 | private Exception StartEventHandler(ScriptEventCode newEventCode, object[] newEhArgs) |
413 | { | 413 | { |
414 | // We use this.eventCode == ScriptEventCode.None to indicate we are idle. | 414 | // We use this.eventCode == ScriptEventCode.None to indicate we are idle. |
415 | // So trying to execute ScriptEventCode.None might make a mess. | 415 | // So trying to execute ScriptEventCode.None might make a mess. |
416 | if(eventCode == ScriptEventCode.None) | 416 | if(newEventCode == ScriptEventCode.None) |
417 | return new Exception("Can't process ScriptEventCode.None"); | 417 | return new Exception("Can't process ScriptEventCode.None"); |
418 | 418 | ||
419 | // Silly to even try if there is no handler defined for this event. | 419 | // Silly to even try if there is no handler defined for this event. |
420 | if(((int)eventCode >= 0) && (m_ObjCode.scriptEventHandlerTable[this.stateCode, (int)eventCode] == null)) | 420 | if(((int)newEventCode >= 0) && (m_ObjCode.scriptEventHandlerTable[this.stateCode, (int)newEventCode] == null)) |
421 | return null; | 421 | return null; |
422 | 422 | ||
423 | // The microthread shouldn't be processing any event code. | 423 | // The microthread shouldn't be processing any event code. |
@@ -427,8 +427,8 @@ namespace OpenSim.Region.ScriptEngine.Yengine | |||
427 | 427 | ||
428 | // Save eventCode so we know what event handler to run in the microthread. | 428 | // Save eventCode so we know what event handler to run in the microthread. |
429 | // And it also marks us busy so we can't be started again and this event lost. | 429 | // And it also marks us busy so we can't be started again and this event lost. |
430 | this.eventCode = eventCode; | 430 | this.eventCode = newEventCode; |
431 | this.ehArgs = ehArgs; | 431 | this.ehArgs = newEhArgs; |
432 | 432 | ||
433 | // This calls ScriptUThread.Main() directly, and returns when Main() [indirectly] | 433 | // This calls ScriptUThread.Main() directly, and returns when Main() [indirectly] |
434 | // calls Suspend() or when Main() returns, whichever occurs first. | 434 | // calls Suspend() or when Main() returns, whichever occurs first. |
@@ -580,7 +580,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine | |||
580 | */ | 580 | */ |
581 | public void Reset() | 581 | public void Reset() |
582 | { | 582 | { |
583 | checkstate: | 583 | checkstate: |
584 | XMRInstState iState = m_IState; | 584 | XMRInstState iState = m_IState; |
585 | switch(iState) | 585 | switch(iState) |
586 | { | 586 | { |
@@ -834,17 +834,12 @@ namespace OpenSim.Region.ScriptEngine.Yengine | |||
834 | 834 | ||
835 | switch(this.callMode) | 835 | switch(this.callMode) |
836 | { | 836 | { |
837 | // Now we are ready to suspend the microthread. | 837 | // Now we are ready to suspend or resume. |
838 | // This is like a longjmp() to the most recent StartEx() or ResumeEx() | ||
839 | // with a simultaneous setjmp() so ResumeEx() can longjmp() back here. | ||
840 | |||
841 | // the script event handler wants to hibernate | ||
842 | // capture stack frames and unwind to Start() or Resume() | ||
843 | case CallMode_NORMAL: | 838 | case CallMode_NORMAL: |
844 | m_CheckRunPhase = "suspending"; | 839 | m_CheckRunPhase = "suspending"; |
845 | callMode = XMRInstance.CallMode_SAVE; | 840 | callMode = XMRInstance.CallMode_SAVE; |
846 | stackFrames = null; | 841 | stackFrames = null; |
847 | throw new StackHibernateException(); | 842 | throw new StackHibernateException(); // does not return |
848 | 843 | ||
849 | // We get here when the script state has been read in by MigrateInEventHandler(). | 844 | // We get here when the script state has been read in by MigrateInEventHandler(). |
850 | // Since the stack is completely restored at this point, any subsequent calls | 845 | // Since the stack is completely restored at this point, any subsequent calls |