Use the same web fetch handler for every request from every avatar, since it contains no instance code

iar_mods
Justin Clark-Casey (justincc) 2011-11-26 00:29:01 +00:00
parent c5b636469d
commit 11c19b0d2e
1 changed files with 11 additions and 3 deletions

View File

@ -60,6 +60,8 @@ namespace OpenSim.Region.ClientStack.Linden
private string m_fetchInventoryDescendents2Url; private string m_fetchInventoryDescendents2Url;
private string m_webFetchInventoryDescendentsUrl; private string m_webFetchInventoryDescendentsUrl;
private WebFetchInvDescHandler m_webFetchHandler;
#region ISharedRegionModule Members #region ISharedRegionModule Members
public void Initialise(IConfigSource source) public void Initialise(IConfigSource source)
@ -72,8 +74,10 @@ namespace OpenSim.Region.ClientStack.Linden
m_webFetchInventoryDescendentsUrl = config.GetString("Cap_WebFetchInventoryDescendents", string.Empty); m_webFetchInventoryDescendentsUrl = config.GetString("Cap_WebFetchInventoryDescendents", string.Empty);
if (m_fetchInventoryDescendents2Url != string.Empty || m_webFetchInventoryDescendentsUrl != string.Empty) if (m_fetchInventoryDescendents2Url != string.Empty || m_webFetchInventoryDescendentsUrl != string.Empty)
{
m_Enabled = true; m_Enabled = true;
} }
}
public void AddRegion(Scene s) public void AddRegion(Scene s)
{ {
@ -97,8 +101,13 @@ namespace OpenSim.Region.ClientStack.Linden
if (!m_Enabled) if (!m_Enabled)
return; return;
m_InventoryService = m_scene.InventoryService; ; m_InventoryService = m_scene.InventoryService;
m_LibraryService = m_scene.LibraryService; m_LibraryService = m_scene.LibraryService;
// We'll reuse the same handler for all requests.
if (m_fetchInventoryDescendents2Url == "localhost" || m_webFetchInventoryDescendentsUrl == "localhost")
m_webFetchHandler = new WebFetchInvDescHandler(m_InventoryService, m_LibraryService);
m_scene.EventManager.OnRegisterCaps += RegisterCaps; m_scene.EventManager.OnRegisterCaps += RegisterCaps;
} }
@ -134,9 +143,8 @@ namespace OpenSim.Region.ClientStack.Linden
{ {
capUrl = "/CAPS/" + UUID.Random(); capUrl = "/CAPS/" + UUID.Random();
WebFetchInvDescHandler webFetchHandler = new WebFetchInvDescHandler(m_InventoryService, m_LibraryService);
IRequestHandler reqHandler IRequestHandler reqHandler
= new RestStreamHandler("POST", capUrl, webFetchHandler.FetchInventoryDescendentsRequest); = new RestStreamHandler("POST", capUrl, m_webFetchHandler.FetchInventoryDescendentsRequest);
caps.RegisterHandler(capName, reqHandler); caps.RegisterHandler(capName, reqHandler);
} }