aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/YEngine/MMRScriptCompile.cs
diff options
context:
space:
mode:
authorUbitUmarov2018-03-09 21:33:39 +0000
committerUbitUmarov2018-03-09 21:33:39 +0000
commitc723a1be16307850055a9644f705f63f74df0c39 (patch)
treed2384aa7ade0f77a3bff00b749dd99f9a23f007e /OpenSim/Region/ScriptEngine/YEngine/MMRScriptCompile.cs
parentMerge branch 'master' into httptests (diff)
downloadopensim-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/ScriptEngine/YEngine/MMRScriptCompile.cs')
-rw-r--r--OpenSim/Region/ScriptEngine/YEngine/MMRScriptCompile.cs33
1 files changed, 16 insertions, 17 deletions
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 }