Merge branch 'master' of /home/opensim/var/repo/opensim

integration
BlueWall 2012-06-23 03:32:58 -04:00
commit 4290ae59f4
8 changed files with 239 additions and 187 deletions

View File

@ -321,7 +321,7 @@ namespace OpenSim.Framework.Servers
TimeSpan timeTaken = DateTime.Now - m_startuptime; TimeSpan timeTaken = DateTime.Now - m_startuptime;
m_log.InfoFormat( m_log.InfoFormat(
"[STARTUP]: Non-script portion of startup took {0}m {1}s. PLEASE WAIT FOR LOGINS TO BE ENABLED ON REGIONS.", "[STARTUP]: Non-script portion of startup took {0}m {1}s. PLEASE WAIT FOR LOGINS TO BE ENABLED ON REGIONS ONCE SCRIPTS HAVE STARTED.",
timeTaken.Minutes, timeTaken.Seconds); timeTaken.Minutes, timeTaken.Seconds);
} }

View File

@ -28,6 +28,7 @@
using System; using System;
using System.Collections; using System.Collections;
using OpenMetaverse; using OpenMetaverse;
namespace OpenSim.Framework.Servers.HttpServer namespace OpenSim.Framework.Servers.HttpServer
{ {
public delegate void RequestMethod(UUID requestID, Hashtable request); public delegate void RequestMethod(UUID requestID, Hashtable request);
@ -44,7 +45,11 @@ namespace OpenSim.Framework.Servers.HttpServer
public NoEventsMethod NoEvents; public NoEventsMethod NoEvents;
public RequestMethod Request; public RequestMethod Request;
public UUID Id; public UUID Id;
public PollServiceEventArgs(RequestMethod pRequest, HasEventsMethod pHasEvents, GetEventsMethod pGetEvents, NoEventsMethod pNoEvents,UUID pId)
public PollServiceEventArgs(
RequestMethod pRequest,
HasEventsMethod pHasEvents, GetEventsMethod pGetEvents, NoEventsMethod pNoEvents,
UUID pId)
{ {
Request = pRequest; Request = pRequest;
HasEvents = pHasEvents; HasEvents = pHasEvents;

View File

@ -31,7 +31,6 @@ using OpenMetaverse;
namespace OpenSim.Framework.Servers.HttpServer namespace OpenSim.Framework.Servers.HttpServer
{ {
public class PollServiceHttpRequest public class PollServiceHttpRequest
{ {
public readonly PollServiceEventArgs PollServiceArgs; public readonly PollServiceEventArgs PollServiceArgs;
@ -39,7 +38,9 @@ namespace OpenSim.Framework.Servers.HttpServer
public readonly IHttpRequest Request; public readonly IHttpRequest Request;
public readonly int RequestTime; public readonly int RequestTime;
public readonly UUID RequestID; public readonly UUID RequestID;
public PollServiceHttpRequest(PollServiceEventArgs pPollServiceArgs, IHttpClientContext pHttpContext, IHttpRequest pRequest)
public PollServiceHttpRequest(
PollServiceEventArgs pPollServiceArgs, IHttpClientContext pHttpContext, IHttpRequest pRequest)
{ {
PollServiceArgs = pPollServiceArgs; PollServiceArgs = pPollServiceArgs;
HttpContext = pHttpContext; HttpContext = pHttpContext;

View File

@ -408,17 +408,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
if (!Enabled) if (!Enabled)
return; return;
// First we save the
// attachment point information, then we update the relative
// positioning. Then we have to mark the object as NOT an
// attachment. This is necessary in order to correctly save
// and retrieve GroupPosition information for the attachment.
// Finally, we restore the object's attachment status.
uint attachmentPoint = sog.AttachmentPoint;
sog.UpdateGroupPosition(pos); sog.UpdateGroupPosition(pos);
sog.IsAttachment = false;
sog.AbsolutePosition = sog.RootPart.AttachedPos;
sog.AttachmentPoint = attachmentPoint;
sog.HasGroupChanged = true; sog.HasGroupChanged = true;
} }

View File

@ -41,13 +41,39 @@ using OpenSim.Region.Framework.Scenes;
namespace OpenSim.Region.CoreModules.Scripting.LSLHttp namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
{ {
/// <summary>
/// Data describing an external URL set up by a script.
/// </summary>
public class UrlData public class UrlData
{ {
/// <summary>
/// Scene object part hosting the script
/// </summary>
public UUID hostID; public UUID hostID;
/// <summary>
/// The item ID of the script that requested the URL.
/// </summary>
public UUID itemID; public UUID itemID;
/// <summary>
/// The script engine that runs the script.
/// </summary>
public IScriptModule engine; public IScriptModule engine;
/// <summary>
/// The generated URL.
/// </summary>
public string url; public string url;
/// <summary>
/// The random UUID component of the generated URL.
/// </summary>
public UUID urlcode; public UUID urlcode;
/// <summary>
/// The external requests currently being processed or awaiting retrieval for this URL.
/// </summary>
public Dictionary<UUID, RequestData> requests; public Dictionary<UUID, RequestData> requests;
} }
@ -64,17 +90,29 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
public string uri; public string uri;
} }
/// <summary>
/// This module provides external URLs for in-world scripts.
/// </summary>
public class UrlModule : ISharedRegionModule, IUrlModule public class UrlModule : ISharedRegionModule, IUrlModule
{ {
private static readonly ILog m_log = private static readonly ILog m_log =
LogManager.GetLogger( LogManager.GetLogger(
MethodBase.GetCurrentMethod().DeclaringType); MethodBase.GetCurrentMethod().DeclaringType);
private Dictionary<UUID, UrlData> m_RequestMap = /// <summary>
new Dictionary<UUID, UrlData>(); /// Indexs the URL request metadata (which script requested it, outstanding requests, etc.) by the request ID
/// randomly generated when a request is received for this URL.
/// </summary>
/// <remarks>
/// Manipulation or retrieval from this dictionary must be locked on m_UrlMap to preserve consistency with
/// m_UrlMap
/// </remarks>
private Dictionary<UUID, UrlData> m_RequestMap = new Dictionary<UUID, UrlData>();
private Dictionary<string, UrlData> m_UrlMap = /// <summary>
new Dictionary<string, UrlData>(); /// Indexs the URL request metadata (which script requested it, outstanding requests, etc.) by the full URL
/// </summary>
private Dictionary<string, UrlData> m_UrlMap = new Dictionary<string, UrlData>();
/// <summary> /// <summary>
/// Maximum number of external urls that can be set up by this module. /// Maximum number of external urls that can be set up by this module.
@ -105,10 +143,9 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
{ {
m_ExternalHostNameForLSL = config.Configs["Network"].GetString("ExternalHostNameForLSL", System.Environment.MachineName); m_ExternalHostNameForLSL = config.Configs["Network"].GetString("ExternalHostNameForLSL", System.Environment.MachineName);
bool ssl_enabled = config.Configs["Network"].GetBoolean("https_listener",false); bool ssl_enabled = config.Configs["Network"].GetBoolean("https_listener",false);
if (ssl_enabled) if (ssl_enabled)
{
https_port = (uint) config.Configs["Network"].GetInt("https_port",0); https_port = (uint) config.Configs["Network"].GetInt("https_port",0);
}
IConfig llFunctionsConfig = config.Configs["LL-Functions"]; IConfig llFunctionsConfig = config.Configs["LL-Functions"];
@ -224,7 +261,6 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
urlData.urlcode = urlcode; urlData.urlcode = urlcode;
urlData.requests = new Dictionary<UUID, RequestData>(); urlData.requests = new Dictionary<UUID, RequestData>();
m_UrlMap[url] = urlData; m_UrlMap[url] = urlData;
string uri = "/lslhttps/" + urlcode.ToString() + "/"; string uri = "/lslhttps/" + urlcode.ToString() + "/";
@ -267,6 +303,8 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
} }
public void HttpResponse(UUID request, int status, string body) public void HttpResponse(UUID request, int status, string body)
{
lock (m_UrlMap)
{ {
if (m_RequestMap.ContainsKey(request)) if (m_RequestMap.ContainsKey(request))
{ {
@ -281,8 +319,11 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
m_log.Info("[HttpRequestHandler] There is no http-in request with id " + request.ToString()); m_log.Info("[HttpRequestHandler] There is no http-in request with id " + request.ToString());
} }
} }
}
public string GetHttpHeader(UUID requestId, string header) public string GetHttpHeader(UUID requestId, string header)
{
lock (m_UrlMap)
{ {
if (m_RequestMap.ContainsKey(requestId)) if (m_RequestMap.ContainsKey(requestId))
{ {
@ -295,11 +336,14 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
{ {
m_log.Warn("[HttpRequestHandler] There was no http-in request with id " + requestId); m_log.Warn("[HttpRequestHandler] There was no http-in request with id " + requestId);
} }
}
return String.Empty; return String.Empty;
} }
public int GetFreeUrls() public int GetFreeUrls()
{ {
lock (m_UrlMap)
return m_TotalUrls - m_UrlMap.Count; return m_TotalUrls - m_UrlMap.Count;
} }
@ -339,6 +383,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
{ {
RemoveUrl(url.Value); RemoveUrl(url.Value);
removeURLs.Add(url.Key); removeURLs.Add(url.Key);
foreach (UUID req in url.Value.requests.Keys) foreach (UUID req in url.Value.requests.Keys)
m_RequestMap.Remove(req); m_RequestMap.Remove(req);
} }
@ -349,7 +394,6 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
} }
} }
private void RemoveUrl(UrlData data) private void RemoveUrl(UrlData data)
{ {
m_HttpServer.RemoveHTTPHandler("", "/lslhttp/" + data.urlcode.ToString() + "/"); m_HttpServer.RemoveHTTPHandler("", "/lslhttp/" + data.urlcode.ToString() + "/");
@ -358,15 +402,26 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
private Hashtable NoEvents(UUID requestID, UUID sessionID) private Hashtable NoEvents(UUID requestID, UUID sessionID)
{ {
Hashtable response = new Hashtable(); Hashtable response = new Hashtable();
UrlData url; UrlData urlData;
lock (m_RequestMap)
lock (m_UrlMap)
{ {
// We need to return a 404 here in case the request URL was removed at exactly the same time that a
// request was made. In this case, the request thread can outrace llRemoveURL() and still be polling
// for the request ID.
if (!m_RequestMap.ContainsKey(requestID)) if (!m_RequestMap.ContainsKey(requestID))
{
response["int_response_code"] = 404;
response["str_response_string"] = "";
response["keepalive"] = false;
response["reusecontext"] = false;
return response; return response;
url = m_RequestMap[requestID];
} }
if (System.Environment.TickCount - url.requests[requestID].startTime > 25000) urlData = m_RequestMap[requestID];
if (System.Environment.TickCount - urlData.requests[requestID].startTime > 25000)
{ {
response["int_response_code"] = 500; response["int_response_code"] = 500;
response["str_response_string"] = "Script timeout"; response["str_response_string"] = "Script timeout";
@ -375,64 +430,66 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
response["reusecontext"] = false; response["reusecontext"] = false;
//remove from map //remove from map
lock (url) urlData.requests.Remove(requestID);
{
url.requests.Remove(requestID);
m_RequestMap.Remove(requestID); m_RequestMap.Remove(requestID);
}
return response; return response;
} }
}
return response; return response;
} }
private bool HasEvents(UUID requestID, UUID sessionID) private bool HasEvents(UUID requestID, UUID sessionID)
{ {
UrlData url=null; lock (m_UrlMap)
lock (m_RequestMap)
{ {
// We return true here because an external URL request that happened at the same time as an llRemoveURL()
// can still make it through to HttpRequestHandler(). That will return without setting up a request
// when it detects that the URL has been removed. The poller, however, will continue to ask for
// events for that request, so here we will signal that there are events and in GetEvents we will
// return a 404.
if (!m_RequestMap.ContainsKey(requestID)) if (!m_RequestMap.ContainsKey(requestID))
{ {
return false; return true;
}
url = m_RequestMap[requestID];
if (!url.requests.ContainsKey(requestID))
{
return false;
}
} }
if (System.Environment.TickCount-url.requests[requestID].startTime>25000) UrlData urlData = m_RequestMap[requestID];
if (!urlData.requests.ContainsKey(requestID))
{ {
return true; return true;
} }
if (url.requests[requestID].requestDone) // Trigger return of timeout response.
if (System.Environment.TickCount - urlData.requests[requestID].startTime > 25000)
{
return true; return true;
else
return false;
} }
return urlData.requests[requestID].requestDone;
}
}
private Hashtable GetEvents(UUID requestID, UUID sessionID, string request) private Hashtable GetEvents(UUID requestID, UUID sessionID, string request)
{
Hashtable response;
lock (m_UrlMap)
{ {
UrlData url = null; UrlData url = null;
RequestData requestData = null; RequestData requestData = null;
lock (m_RequestMap)
{
if (!m_RequestMap.ContainsKey(requestID)) if (!m_RequestMap.ContainsKey(requestID))
return NoEvents(requestID, sessionID); return NoEvents(requestID, sessionID);
url = m_RequestMap[requestID]; url = m_RequestMap[requestID];
requestData = url.requests[requestID]; requestData = url.requests[requestID];
}
if (!requestData.requestDone) if (!requestData.requestDone)
return NoEvents(requestID, sessionID); return NoEvents(requestID, sessionID);
Hashtable response = new Hashtable(); response = new Hashtable();
if (System.Environment.TickCount - requestData.startTime > 25000) if (System.Environment.TickCount - requestData.startTime > 25000)
{ {
@ -443,6 +500,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
response["reusecontext"] = false; response["reusecontext"] = false;
return response; return response;
} }
//put response //put response
response["int_response_code"] = requestData.responseCode; response["int_response_code"] = requestData.responseCode;
response["str_response_string"] = requestData.responseBody; response["str_response_string"] = requestData.responseBody;
@ -451,17 +509,14 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
response["reusecontext"] = false; response["reusecontext"] = false;
//remove from map //remove from map
lock (url)
{
url.requests.Remove(requestID); url.requests.Remove(requestID);
m_RequestMap.Remove(requestID); m_RequestMap.Remove(requestID);
} }
return response; return response;
} }
public void HttpRequestHandler(UUID requestID, Hashtable request) public void HttpRequestHandler(UUID requestID, Hashtable request)
{
lock (request)
{ {
string uri = request["uri"].ToString(); string uri = request["uri"].ToString();
bool is_ssl = uri.Contains("lslhttps"); bool is_ssl = uri.Contains("lslhttps");
@ -483,11 +538,21 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
pathInfo = uri.Substring(pos3); pathInfo = uri.Substring(pos3);
UrlData url = null; UrlData urlData = null;
if (!is_ssl)
url = m_UrlMap["http://" + m_ExternalHostNameForLSL + ":" + m_HttpServer.Port.ToString() + uri_tmp]; lock (m_UrlMap)
{
string url;
if (is_ssl)
url = "https://" + m_ExternalHostNameForLSL + ":" + m_HttpsServer.Port.ToString() + uri_tmp;
else else
url = m_UrlMap["https://" + m_ExternalHostNameForLSL + ":" + m_HttpsServer.Port.ToString() + uri_tmp]; url = "http://" + m_ExternalHostNameForLSL + ":" + m_HttpServer.Port.ToString() + uri_tmp;
// Avoid a race - the request URL may have been released via llRequestUrl() whilst this
// request was being processed.
if (!m_UrlMap.TryGetValue(url, out urlData))
return;
//for llGetHttpHeader support we need to store original URI here //for llGetHttpHeader support we need to store original URI here
//to make x-path-info / x-query-string / x-script-url / x-remote-ip headers //to make x-path-info / x-query-string / x-script-url / x-remote-ip headers
@ -507,6 +572,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
string value = (string)header.Value; string value = (string)header.Value;
requestData.headers.Add(key, value); requestData.headers.Add(key, value);
} }
foreach (DictionaryEntry de in request) foreach (DictionaryEntry de in request)
{ {
if (de.Key.ToString() == "querystringkeys") if (de.Key.ToString() == "querystringkeys")
@ -520,11 +586,10 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
queryString = queryString + key + "=" + val + "&"; queryString = queryString + key + "=" + val + "&";
} }
} }
if (queryString.Length > 1) if (queryString.Length > 1)
queryString = queryString.Substring(0, queryString.Length - 1); queryString = queryString.Substring(0, queryString.Length - 1);
} }
} }
//if this machine is behind DNAT/port forwarding, currently this is being //if this machine is behind DNAT/port forwarding, currently this is being
@ -532,26 +597,16 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
requestData.headers["x-remote-ip"] = requestData.headers["remote_addr"]; requestData.headers["x-remote-ip"] = requestData.headers["remote_addr"];
requestData.headers["x-path-info"] = pathInfo; requestData.headers["x-path-info"] = pathInfo;
requestData.headers["x-query-string"] = queryString; requestData.headers["x-query-string"] = queryString;
requestData.headers["x-script-url"] = url.url; requestData.headers["x-script-url"] = urlData.url;
//requestData.ev = new ManualResetEvent(false); urlData.requests.Add(requestID, requestData);
lock (url.requests) m_RequestMap.Add(requestID, urlData);
{
url.requests.Add(requestID, requestData);
}
lock (m_RequestMap)
{
//add to request map
m_RequestMap.Add(requestID, url);
} }
url.engine.PostScriptEvent(url.itemID, "http_request", new Object[] { requestID.ToString(), request["http-method"].ToString(), request["body"].ToString() }); urlData.engine.PostScriptEvent(
urlData.itemID,
//send initial response? "http_request",
// Hashtable response = new Hashtable(); new Object[] { requestID.ToString(), request["http-method"].ToString(), request["body"].ToString() });
return;
} }
catch (Exception we) catch (Exception we)
{ {
@ -561,7 +616,6 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
m_log.Warn(we.StackTrace); m_log.Warn(we.StackTrace);
} }
} }
}
private void OnScriptReset(uint localID, UUID itemID) private void OnScriptReset(uint localID, UUID itemID)
{ {

View File

@ -2911,6 +2911,11 @@ namespace OpenSim.Region.Framework.Scenes
m_scene.PhysicsScene.AddPhysicsActorTaint(actor); m_scene.PhysicsScene.AddPhysicsActorTaint(actor);
} }
if (IsAttachment)
{
m_rootPart.AttachedPos = pos;
}
AbsolutePosition = pos; AbsolutePosition = pos;
HasGroupChanged = true; HasGroupChanged = true;

View File

@ -853,15 +853,9 @@ namespace OpenSim.Region.ScriptEngine.XEngine
{ {
if (m_InitialStartup) if (m_InitialStartup)
{ {
m_InitialStartup = false; // This delay exists to stop mono problems where script compilation and startup would stop the sim
// working properly for the session.
System.Threading.Thread.Sleep(15000); System.Threading.Thread.Sleep(15000);
if (m_CompileQueue.Count == 0)
{
// No scripts on region, so won't get triggered later
// by the queue becoming empty so we trigger it here
m_Scene.EventManager.TriggerEmptyScriptCompileQueue(0, String.Empty);
}
} }
object[] o; object[] o;
@ -874,14 +868,16 @@ namespace OpenSim.Region.ScriptEngine.XEngine
{ {
scriptsStarted++; scriptsStarted++;
// if (scriptsStarted % 50 == 0) if (m_InitialStartup)
// m_log.DebugFormat( if (scriptsStarted % 50 == 0)
// "[XEngine]: Started {0} scripts in {1}", scriptsStarted, m_Scene.RegionInfo.RegionName); m_log.InfoFormat(
"[XEngine]: Started {0} scripts in {1}", scriptsStarted, m_Scene.RegionInfo.RegionName);
} }
} }
// m_log.DebugFormat( if (m_InitialStartup)
// "[XEngine]: Completed starting {0} scripts on {1}", scriptsStarted, m_Scene.RegionInfo.RegionName); m_log.InfoFormat(
"[XEngine]: Completed starting {0} scripts on {1}", scriptsStarted, m_Scene.RegionInfo.RegionName);
// NOTE: Despite having a lockless queue, this lock is required // NOTE: Despite having a lockless queue, this lock is required
// to make sure there is never no compile thread while there // to make sure there is never no compile thread while there
@ -889,12 +885,13 @@ namespace OpenSim.Region.ScriptEngine.XEngine
// due to a race condition // due to a race condition
// //
lock (m_CompileQueue) lock (m_CompileQueue)
{
m_CurrentCompile = null; m_CurrentCompile = null;
}
m_Scene.EventManager.TriggerEmptyScriptCompileQueue(m_ScriptFailCount, m_Scene.EventManager.TriggerEmptyScriptCompileQueue(m_ScriptFailCount,
m_ScriptErrorMessage); m_ScriptErrorMessage);
m_ScriptFailCount = 0; m_ScriptFailCount = 0;
m_InitialStartup = false;
return null; return null;
} }
@ -1366,7 +1363,6 @@ namespace OpenSim.Region.ScriptEngine.XEngine
return false; return false;
uuids = m_PrimObjects[localID]; uuids = m_PrimObjects[localID];
}
foreach (UUID itemID in uuids) foreach (UUID itemID in uuids)
{ {
@ -1384,6 +1380,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
result = true; result = true;
} }
} }
}
return result; return result;
} }

View File

@ -33,7 +33,7 @@
</root> </root>
<logger name="OpenSim.Region.ScriptEngine.XEngine"> <logger name="OpenSim.Region.ScriptEngine.XEngine">
<level value="WARN"/> <level value="INFO"/>
</logger> </logger>
</log4net> </log4net>