aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2013-02-26 23:36:36 +0000
committerJustin Clark-Casey (justincc)2013-02-26 23:36:36 +0000
commitb8a7c8b26f3005eed5b161c37509b06b1d604967 (patch)
tree67304ff03ac6331b33bfa75201da1a529feec0bd
parentBulletSim: fix crash around race condition when a mesh asset cannot (diff)
downloadopensim-SC-b8a7c8b26f3005eed5b161c37509b06b1d604967.zip
opensim-SC-b8a7c8b26f3005eed5b161c37509b06b1d604967.tar.gz
opensim-SC-b8a7c8b26f3005eed5b161c37509b06b1d604967.tar.bz2
opensim-SC-b8a7c8b26f3005eed5b161c37509b06b1d604967.tar.xz
Add regression test for llRequestUrl()
-rw-r--r--OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs37
-rw-r--r--OpenSim/Region/Framework/Interfaces/IScriptModule.cs11
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs1
-rw-r--r--OpenSim/Tests/Common/Mock/MockScriptEngine.cs57
-rw-r--r--prebuild.xml2
5 files changed, 86 insertions, 22 deletions
diff --git a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs
index be617a5..79e633f 100644
--- a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs
+++ b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs
@@ -122,15 +122,11 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
122 /// </summary> 122 /// </summary>
123 private int m_TotalUrls = 100; 123 private int m_TotalUrls = 100;
124 124
125 private uint https_port = 0; 125 private uint m_HttpsPort = 0;
126 private IHttpServer m_HttpServer = null; 126 private IHttpServer m_HttpServer = null;
127 private IHttpServer m_HttpsServer = null; 127 private IHttpServer m_HttpsServer = null;
128 128
129 private string m_ExternalHostNameForLSL = ""; 129 public string ExternalHostNameForLSL { get; private set; }
130 public string ExternalHostNameForLSL
131 {
132 get { return m_ExternalHostNameForLSL; }
133 }
134 130
135 public Type ReplaceableInterface 131 public Type ReplaceableInterface
136 { 132 {
@@ -144,11 +140,20 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
144 140
145 public void Initialise(IConfigSource config) 141 public void Initialise(IConfigSource config)
146 { 142 {
147 m_ExternalHostNameForLSL = config.Configs["Network"].GetString("ExternalHostNameForLSL", System.Environment.MachineName); 143 IConfig networkConfig = config.Configs["Network"];
148 bool ssl_enabled = config.Configs["Network"].GetBoolean("https_listener",false); 144
145 if (networkConfig != null)
146 {
147 ExternalHostNameForLSL = config.Configs["Network"].GetString("ExternalHostNameForLSL", null);
148
149 bool ssl_enabled = config.Configs["Network"].GetBoolean("https_listener", false);
150
151 if (ssl_enabled)
152 m_HttpsPort = (uint)config.Configs["Network"].GetInt("https_port", (int)m_HttpsPort);
153 }
149 154
150 if (ssl_enabled) 155 if (ExternalHostNameForLSL == null)
151 https_port = (uint) config.Configs["Network"].GetInt("https_port",0); 156 ExternalHostNameForLSL = System.Environment.MachineName;
152 157
153 IConfig llFunctionsConfig = config.Configs["LL-Functions"]; 158 IConfig llFunctionsConfig = config.Configs["LL-Functions"];
154 159
@@ -169,9 +174,9 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
169 m_HttpServer = MainServer.Instance; 174 m_HttpServer = MainServer.Instance;
170 // 175 //
171 // We can use the https if it is enabled 176 // We can use the https if it is enabled
172 if (https_port > 0) 177 if (m_HttpsPort > 0)
173 { 178 {
174 m_HttpsServer = MainServer.GetHttpServer(https_port); 179 m_HttpsServer = MainServer.GetHttpServer(m_HttpsPort);
175 } 180 }
176 } 181 }
177 182
@@ -209,7 +214,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
209 engine.PostScriptEvent(itemID, "http_request", new Object[] { urlcode.ToString(), "URL_REQUEST_DENIED", "" }); 214 engine.PostScriptEvent(itemID, "http_request", new Object[] { urlcode.ToString(), "URL_REQUEST_DENIED", "" });
210 return urlcode; 215 return urlcode;
211 } 216 }
212 string url = "http://" + m_ExternalHostNameForLSL + ":" + m_HttpServer.Port.ToString() + "/lslhttp/" + urlcode.ToString() + "/"; 217 string url = "http://" + ExternalHostNameForLSL + ":" + m_HttpServer.Port.ToString() + "/lslhttp/" + urlcode.ToString() + "/";
213 218
214 UrlData urlData = new UrlData(); 219 UrlData urlData = new UrlData();
215 urlData.hostID = host.UUID; 220 urlData.hostID = host.UUID;
@@ -254,7 +259,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
254 engine.PostScriptEvent(itemID, "http_request", new Object[] { urlcode.ToString(), "URL_REQUEST_DENIED", "" }); 259 engine.PostScriptEvent(itemID, "http_request", new Object[] { urlcode.ToString(), "URL_REQUEST_DENIED", "" });
255 return urlcode; 260 return urlcode;
256 } 261 }
257 string url = "https://" + m_ExternalHostNameForLSL + ":" + m_HttpsServer.Port.ToString() + "/lslhttps/" + urlcode.ToString() + "/"; 262 string url = "https://" + ExternalHostNameForLSL + ":" + m_HttpsServer.Port.ToString() + "/lslhttps/" + urlcode.ToString() + "/";
258 263
259 UrlData urlData = new UrlData(); 264 UrlData urlData = new UrlData();
260 urlData.hostID = host.UUID; 265 urlData.hostID = host.UUID;
@@ -579,9 +584,9 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
579 string url; 584 string url;
580 585
581 if (is_ssl) 586 if (is_ssl)
582 url = "https://" + m_ExternalHostNameForLSL + ":" + m_HttpsServer.Port.ToString() + uri_tmp; 587 url = "https://" + ExternalHostNameForLSL + ":" + m_HttpsServer.Port.ToString() + uri_tmp;
583 else 588 else
584 url = "http://" + m_ExternalHostNameForLSL + ":" + m_HttpServer.Port.ToString() + uri_tmp; 589 url = "http://" + ExternalHostNameForLSL + ":" + m_HttpServer.Port.ToString() + uri_tmp;
585 590
586 // Avoid a race - the request URL may have been released via llRequestUrl() whilst this 591 // Avoid a race - the request URL may have been released via llRequestUrl() whilst this
587 // request was being processed. 592 // request was being processed.
diff --git a/OpenSim/Region/Framework/Interfaces/IScriptModule.cs b/OpenSim/Region/Framework/Interfaces/IScriptModule.cs
index 143af48..ced4e91 100644
--- a/OpenSim/Region/Framework/Interfaces/IScriptModule.cs
+++ b/OpenSim/Region/Framework/Interfaces/IScriptModule.cs
@@ -52,7 +52,18 @@ namespace OpenSim.Region.Framework.Interfaces
52 string GetXMLState(UUID itemID); 52 string GetXMLState(UUID itemID);
53 bool SetXMLState(UUID itemID, string xml); 53 bool SetXMLState(UUID itemID, string xml);
54 54
55 /// <summary>
56 /// Post a script event to a single script.
57 /// </summary>
58 /// <returns>true if the post suceeded, false if it did not</returns>
59 /// <param name='itemID'>The item ID of the script.</param>
60 /// <param name='name'>The name of the event.</param>
61 /// <param name='args'>
62 /// The arguments of the event. These are in the order in which they appear.
63 /// e.g. for http_request this will be an object array of key request_id, string method, string body
64 /// </param>
55 bool PostScriptEvent(UUID itemID, string name, Object[] args); 65 bool PostScriptEvent(UUID itemID, string name, Object[] args);
66
56 bool PostObjectEvent(UUID itemID, string name, Object[] args); 67 bool PostObjectEvent(UUID itemID, string name, Object[] args);
57 68
58 /// <summary> 69 /// <summary>
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 96f650e..6a31568 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -9423,6 +9423,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9423 return UUID.Zero.ToString(); 9423 return UUID.Zero.ToString();
9424 } 9424 }
9425 } 9425 }
9426
9426 public LSL_String llRequestURL() 9427 public LSL_String llRequestURL()
9427 { 9428 {
9428 m_host.AddScriptLPS(1); 9429 m_host.AddScriptLPS(1);
diff --git a/OpenSim/Tests/Common/Mock/MockScriptEngine.cs b/OpenSim/Tests/Common/Mock/MockScriptEngine.cs
index 78bab5b..6a53fe7 100644
--- a/OpenSim/Tests/Common/Mock/MockScriptEngine.cs
+++ b/OpenSim/Tests/Common/Mock/MockScriptEngine.cs
@@ -40,10 +40,33 @@ namespace OpenSim.Tests.Common
40{ 40{
41 public class MockScriptEngine : INonSharedRegionModule, IScriptModule, IScriptEngine 41 public class MockScriptEngine : INonSharedRegionModule, IScriptModule, IScriptEngine
42 { 42 {
43 public IConfigSource ConfigSource { get; private set; }
44
45 public IConfig Config { get; private set; }
46
43 private Scene m_scene; 47 private Scene m_scene;
44 48
49 /// <summary>
50 /// Expose posted events to tests.
51 /// </summary>
52 public Dictionary<UUID, List<EventParams>> PostedEvents { get; private set; }
53
54 /// <summary>
55 /// A very primitive way of hooking text cose to a posed event.
56 /// </summary>
57 /// <remarks>
58 /// May be replaced with something that uses more original code in the future.
59 /// </remarks>
60 public event Action<UUID, EventParams> PostEventHook;
61
45 public void Initialise(IConfigSource source) 62 public void Initialise(IConfigSource source)
46 { 63 {
64 ConfigSource = source;
65
66 // Can set later on if required
67 Config = new IniConfig("MockScriptEngine", ConfigSource);
68
69 PostedEvents = new Dictionary<UUID, List<EventParams>>();
47 } 70 }
48 71
49 public void Close() 72 public void Close()
@@ -85,7 +108,28 @@ namespace OpenSim.Tests.Common
85 108
86 public bool PostScriptEvent(UUID itemID, string name, object[] args) 109 public bool PostScriptEvent(UUID itemID, string name, object[] args)
87 { 110 {
88 return false; 111// Console.WriteLine("Posting event {0} for {1}", name, itemID);
112
113 EventParams evParams = new EventParams(name, args, null);
114
115 List<EventParams> eventsForItem;
116
117 if (!PostedEvents.ContainsKey(itemID))
118 {
119 eventsForItem = new List<EventParams>();
120 PostedEvents.Add(itemID, eventsForItem);
121 }
122 else
123 {
124 eventsForItem = PostedEvents[itemID];
125 }
126
127 eventsForItem.Add(evParams);
128
129 if (PostEventHook != null)
130 PostEventHook(itemID, evParams);
131
132 return true;
89 } 133 }
90 134
91 public bool PostObjectEvent(UUID itemID, string name, object[] args) 135 public bool PostObjectEvent(UUID itemID, string name, object[] args)
@@ -195,11 +239,7 @@ namespace OpenSim.Tests.Common
195 239
196 public Scene World { get { return m_scene; } } 240 public Scene World { get { return m_scene; } }
197 241
198 public IScriptModule ScriptModule { get { throw new System.NotImplementedException(); } } 242 public IScriptModule ScriptModule { get { return this; } }
199
200 public IConfig Config { get { throw new System.NotImplementedException (); } }
201
202 public IConfigSource ConfigSource { get { throw new System.NotImplementedException (); } }
203 243
204 public string ScriptEnginePath { get { throw new System.NotImplementedException (); }} 244 public string ScriptEnginePath { get { throw new System.NotImplementedException (); }}
205 245
@@ -210,5 +250,10 @@ namespace OpenSim.Tests.Common
210 public string[] ScriptReferencedAssemblies { get { throw new System.NotImplementedException (); } } 250 public string[] ScriptReferencedAssemblies { get { throw new System.NotImplementedException (); } }
211 251
212 public ParameterInfo[] ScriptBaseClassParameters { get { throw new System.NotImplementedException (); } } 252 public ParameterInfo[] ScriptBaseClassParameters { get { throw new System.NotImplementedException (); } }
253
254 public void ClearPostedEvents()
255 {
256 PostedEvents.Clear();
257 }
213 } 258 }
214} \ No newline at end of file 259} \ No newline at end of file
diff --git a/prebuild.xml b/prebuild.xml
index 7b28085..1e68f67 100644
--- a/prebuild.xml
+++ b/prebuild.xml
@@ -3391,6 +3391,8 @@
3391 <Reference name="System.Xml"/> 3391 <Reference name="System.Xml"/>
3392 <Reference name="OpenSim.Framework"/> 3392 <Reference name="OpenSim.Framework"/>
3393 <Reference name="OpenSim.Framework.Communications"/> 3393 <Reference name="OpenSim.Framework.Communications"/>
3394 <Reference name="OpenSim.Framework.Servers"/>
3395 <Reference name="OpenSim.Framework.Servers.HttpServer"/>
3394 <Reference name="OpenSim.Region.CoreModules"/> 3396 <Reference name="OpenSim.Region.CoreModules"/>
3395 <Reference name="OpenSim.Region.Framework"/> 3397 <Reference name="OpenSim.Region.Framework"/>
3396 <Reference name="OpenSim.Region.OptionalModules"/> 3398 <Reference name="OpenSim.Region.OptionalModules"/>