* First draft resolution of mantis 777, 734, 389 - scripts do not save in non-home regions

* Should work in multi-region standalone and grid modes
* This should also solve other non-home region caps issues (map requests, RC client inventory requests, etc)
* We now pass CAPS information on to the destination region on region crossing, and set up a CAPS object when an agent becomes a master
* Current limitation is that this will only work if your http_listener_port is 9000
* This is a very early code cut (lots of bad practice, hard coding and inefficiency).  However, I wanted to get this out there for feedback and my own sanity.  Next few patches will clean up the mess.
0.6.0-stable
Justin Clarke Casey 2008-03-20 20:04:45 +00:00
parent f61ea1998e
commit c1beb85315
9 changed files with 114 additions and 76 deletions

View File

@ -62,7 +62,12 @@ namespace OpenSim.Region.Capabilities
private string m_httpListenerHostName;
private uint m_httpListenPort;
private string m_capsObjectPath = "00001-";
/// <summary>
/// This is the uuid portion of every CAPS path. It is used to make capability urls private to the requester.
/// </summary>
private string m_capsObjectPath;
public string CapsObjectPath { get { return m_capsObjectPath; } }
private string m_requestPath = "0000/";
private string m_mapLayerPath = "0001/";
private string m_newInventory = "0002/";
@ -109,9 +114,12 @@ namespace OpenSim.Region.Capabilities
try
{
m_httpListener.RemoveStreamHandler("POST", capsBase + m_mapLayerPath);
m_httpListener.AddStreamHandler(
new LLSDStreamhandler<LLSDMapRequest, LLSDMapLayerResponse>("POST", capsBase + m_mapLayerPath,
GetMapLayer));
m_httpListener.RemoveStreamHandler("POST", capsBase + m_newInventory);
m_httpListener.AddStreamHandler(
new LLSDStreamhandler<LLSDAssetUploadRequest, LLSDAssetUploadResponse>("POST",
capsBase + m_newInventory,
@ -142,6 +150,7 @@ namespace OpenSim.Region.Capabilities
private void AddLegacyCapsHandler(BaseHttpServer httpListener, string path, RestMethod restMethod)
{
string capsBase = "/CAPS/" + m_capsObjectPath;
httpListener.RemoveStreamHandler("POST", capsBase + path);
httpListener.AddStreamHandler(new RestStreamHandler("POST", capsBase + path, restMethod));
}

View File

@ -63,5 +63,7 @@ namespace OpenSim.Framework
RegionStatus Region_Status { get; set; }
ClientManager ClientManager { get; }
string GetCapsPath(LLUUID agentId);
}
}

View File

@ -70,14 +70,23 @@ namespace OpenSim.Framework.Servers
m_port = port;
}
/// <summary>
/// Add a stream handler to the http server. If the handler already exists, then nothing happens.
/// </summary>
/// <param name="handler"></param>
public void AddStreamHandler(IRequestHandler handler)
{
string httpMethod = handler.HttpMethod;
string path = handler.Path;
string handlerKey = GetHandlerKey(httpMethod, path);
if (!m_streamHandlers.ContainsKey(handlerKey))
{
//m_log.DebugFormat("[BASE HTTP SERVER]: Adding handler key {0}", handlerKey);
m_streamHandlers.Add(handlerKey, handler);
}
}
private static string GetHandlerKey(string httpMethod, string path)
{
@ -289,7 +298,7 @@ namespace OpenSim.Framework.Servers
}
else
{
System.Console.WriteLine("Handler not found for http request " + request.RawUrl);
m_log.ErrorFormat("[BASE HTTP SERVER] Handler not found for http request {0}", request.RawUrl);
responseString = "Error";
}
}
@ -589,7 +598,11 @@ namespace OpenSim.Framework.Servers
public void RemoveStreamHandler(string httpMethod, string path)
{
m_streamHandlers.Remove(GetHandlerKey(httpMethod, path));
string handlerKey = GetHandlerKey(httpMethod, path);
//m_log.DebugFormat("[BASE HTTP SERVER]: Removing handler key {0}", handlerKey);
m_streamHandlers.Remove(handlerKey);
}
public void RemoveHTTPHandler(string httpMethod, string path)

View File

@ -45,7 +45,6 @@ namespace OpenSim.Framework
private static Random randomClass = new Random();
private static uint nextXferID = 5000;
private static object XferLock = new object();
private static Dictionary<LLUUID, string> capsURLS = new Dictionary<LLUUID, string>();
// Get a list of invalid path characters (OS dependent)
private static string regexInvalidPathChars = "[" + new String(Path.GetInvalidPathChars()) + "]";
@ -422,27 +421,6 @@ namespace OpenSim.Framework
return ".";
}
public static string GetCapsURL(LLUUID userID)
{
if (capsURLS.ContainsKey(userID))
{
return capsURLS[userID];
}
return String.Empty;
}
public static void SetCapsURL(LLUUID userID, string url)
{
if (capsURLS.ContainsKey(userID))
{
capsURLS[userID] = url;
}
else
{
capsURLS.Add(userID, url);
}
}
// Nini (config) related Methods
public static IConfigSource ConvertDataRowToXMLConfig(DataRow row, string fileName)
{

View File

@ -984,7 +984,7 @@ namespace OpenSim.Region.ClientStack
agentData.child = false;
agentData.firstname = m_firstName;
agentData.lastname = m_lastName;
agentData.CapsPath = String.Empty;
agentData.CapsPath = m_scene.GetCapsPath(m_agentId);
return agentData;
}

View File

@ -1649,53 +1649,11 @@ namespace OpenSim.Region.Environment.Scenes
{
if (regionHandle == m_regInfo.RegionHandle)
{
if (agent.CapsPath != String.Empty)
{
m_log.DebugFormat(
"[CONNECTION DEBUGGING]: Setting up CAPS handler for avatar {0} at {1} in {2}",
agent.AgentID, agent.CapsPath, RegionInfo.RegionName);
capsPaths[agent.AgentID] = agent.CapsPath;
Caps cap =
new Caps(AssetCache, m_httpListener, m_regInfo.ExternalHostName, m_httpListener.Port,
agent.CapsPath, agent.AgentID, m_dumpAssetsToFile);
Util.SetCapsURL(agent.AgentID,
"http://" + m_regInfo.ExternalHostName + ":" + m_httpListener.Port.ToString() +
"/CAPS/" + agent.CapsPath + "0000/");
cap.RegisterHandlers();
if (agent.child)
if (!agent.child)
{
}
cap.AddNewInventoryItem = AddInventoryItem;
cap.ItemUpdatedCall = CapsUpdateInventoryItemAsset;
cap.TaskScriptUpdatedCall = CapsUpdateTaskInventoryScriptAsset;
cap.CAPSFetchInventoryDescendents = CommsManager.UserProfileCacheService.HandleFetchInventoryDescendentsCAPS;
if (m_capsHandlers.ContainsKey(agent.AgentID))
{
m_log.DebugFormat(
"[CONNECTION DEBUGGING]: Caps path already in use for avatar {0} in region {1}",
agent.AgentID, RegionInfo.RegionName);
try
{
m_capsHandlers[agent.AgentID] = cap;
}
catch (KeyNotFoundException)
{
m_log.DebugFormat(
"[CONNECTION DEBUGGING]: Caught exception adding handler for avatar {0} at {1}",
agent.AgentID, RegionInfo.RegionName);
// Fix for a potential race condition.
m_capsHandlers.Add(agent.AgentID, cap);
}
}
else
{
m_capsHandlers.Add(agent.AgentID, cap);
}
AddCapsHandler(agent.AgentID);
}
else
{
@ -1718,6 +1676,56 @@ namespace OpenSim.Region.Environment.Scenes
}
}
/// <summary>
/// Add a caps handler for the given agent.
/// </summary>
/// <param name="agentId"></param>
/// <param name="capsObjectPath"></param>
public void AddCapsHandler(LLUUID agentId)
{
String capsObjectPath = GetCapsPath(agentId);
m_log.DebugFormat(
"[CONNECTION DEBUGGING]: Setting up CAPS handler for avatar {0} at {1} in {2}",
agentId, capsObjectPath, RegionInfo.RegionName);
Caps cap =
new Caps(AssetCache, m_httpListener, m_regInfo.ExternalHostName, m_httpListener.Port,
capsObjectPath, agentId, m_dumpAssetsToFile);
cap.RegisterHandlers();
cap.AddNewInventoryItem = AddInventoryItem;
cap.ItemUpdatedCall = CapsUpdateInventoryItemAsset;
cap.TaskScriptUpdatedCall = CapsUpdateTaskInventoryScriptAsset;
cap.CAPSFetchInventoryDescendents = CommsManager.UserProfileCacheService.HandleFetchInventoryDescendentsCAPS;
if (m_capsHandlers.ContainsKey(agentId))
{
m_log.DebugFormat(
"[CONNECTION DEBUGGING]: Caps path already in use for avatar {0} in region {1}",
agentId, RegionInfo.RegionName);
try
{
m_capsHandlers[agentId] = cap;
}
catch (KeyNotFoundException)
{
m_log.DebugFormat(
"[CONNECTION DEBUGGING]: Caught exception adding handler for avatar {0} at {1}",
agentId, RegionInfo.RegionName);
// Fix for a potential race condition.
m_capsHandlers.Add(agentId, cap);
}
}
else
{
m_capsHandlers.Add(agentId, cap);
}
}
/// <summary>
///
/// </summary>

View File

@ -26,6 +26,7 @@
*/
using System;
using System.Collections.Generic;
using libsecondlife;
using OpenSim.Framework;
using OpenSim.Framework.Communications.Cache;
@ -196,5 +197,19 @@ namespace OpenSim.Region.Environment.Scenes
}
#endregion
/// <summary>
/// XXX These two methods are very temporary
/// </summary>
protected Dictionary<LLUUID, String> capsPaths = new Dictionary<LLUUID, String>();
public string GetCapsPath(LLUUID agentId)
{
if (capsPaths.ContainsKey(agentId))
{
return capsPaths[agentId];
}
return null;
}
}
}

View File

@ -483,7 +483,7 @@ namespace OpenSim.Region.Environment.Scenes
}
/// <summary>
///
/// Try to teleport an agent to a new region.
/// </summary>
/// <param name="remoteClient"></param>
/// <param name="RegionHandle"></param>
@ -530,7 +530,11 @@ namespace OpenSim.Region.Environment.Scenes
m_commsProvider.InterRegion.ExpectAvatarCrossing(regionHandle, avatar.ControllingClient.AgentId,
position, false);
AgentCircuitData circuitdata = avatar.ControllingClient.RequestClientInfo();
string capsPath = Util.GetCapsURL(avatar.ControllingClient.AgentId);
// TODO Should construct this behind a method
string capsPath =
"http://" + reg.ExternalHostName + ":" + 9000 + "/CAPS/" + circuitdata.CapsPath + "0000/";
avatar.ControllingClient.SendRegionTeleport(regionHandle, 13, reg.ExternalEndPoint, 4, (1 << 4),
capsPath);
avatar.MakeChildAgent();

View File

@ -545,6 +545,7 @@ namespace OpenSim.Region.Environment.Scenes
m_scene.SwapRootAgentCount(false);
m_scene.CommsManager.UserProfileCacheService.UpdateUserInventory(m_uuid);
m_scene.AddCapsHandler(m_uuid);
//if (!m_gotAllObjectsInScene)
//{
m_scene.SendAllSceneObjectsToClient(this);
@ -1616,7 +1617,15 @@ namespace OpenSim.Region.Environment.Scenes
if (res)
{
AgentCircuitData circuitdata = m_controllingClient.RequestClientInfo();
string capsPath = Util.GetCapsURL(m_controllingClient.AgentId);
// TODO Should construct this behind a method
string capsPath =
"http://" + neighbourRegion.ExternalHostName + ":" + 9000
+ "/CAPS/" + circuitdata.CapsPath + "0000/";
m_log.DebugFormat(
"[CONNECTION DEBUGGING]: Sending new CAPS seed url {0} to avatar {1}", capsPath, m_uuid);
m_controllingClient.CrossRegion(neighbourHandle, newpos, vel, neighbourRegion.ExternalEndPoint,
capsPath);
MakeChildAgent();