do the same to webFecthInvDescModule

avinationmerge
UbitUmarov 2012-09-25 03:59:19 +01:00
parent 2cb17d6fbb
commit 4d681bfde6
1 changed files with 25 additions and 33 deletions

View File

@ -52,6 +52,13 @@ namespace OpenSim.Region.ClientStack.Linden
[Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")]
public class WebFetchInvDescModule : INonSharedRegionModule
{
struct aPollRequest
{
public PollServiceInventoryEventArgs thepoll;
public UUID reqID;
public Hashtable request;
}
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private Scene m_scene;
@ -64,8 +71,8 @@ namespace OpenSim.Region.ClientStack.Linden
private Dictionary<UUID, string> m_capsDict = new Dictionary<UUID, string>();
private static Thread[] m_workerThreads = null;
private static OpenMetaverse.BlockingQueue<PollServiceInventoryEventArgs> m_queue =
new OpenMetaverse.BlockingQueue<PollServiceInventoryEventArgs>();
private static OpenMetaverse.BlockingQueue<aPollRequest> m_queue =
new OpenMetaverse.BlockingQueue<aPollRequest>();
#region ISharedRegionModule Members
@ -131,18 +138,16 @@ namespace OpenSim.Region.ClientStack.Linden
~WebFetchInvDescModule()
{
foreach (Thread t in m_workerThreads)
t.Abort();
Watchdog.AbortThread(t.ManagedThreadId);
}
private class PollServiceInventoryEventArgs : PollServiceEventArgs
{
private List<Hashtable> requests =
new List<Hashtable>();
private Dictionary<UUID, Hashtable> responses =
new Dictionary<UUID, Hashtable>();
public PollServiceInventoryEventArgs(UUID pId) :
base(null, null, null, null, pId, 30000)
base(null, null, null, null, pId, int.MaxValue)
{
HasEvents = (x, y) => { lock (responses) return responses.ContainsKey(x); };
GetEvents = (x, y, s) =>
@ -162,21 +167,23 @@ namespace OpenSim.Region.ClientStack.Linden
Request = (x, y) =>
{
y["RequestID"] = x.ToString();
lock (requests)
requests.Add(y);
aPollRequest reqinfo = new aPollRequest();
reqinfo.thepoll = this;
reqinfo.reqID = x;
reqinfo.request = y;
m_queue.Enqueue(this);
m_queue.Enqueue(reqinfo);
};
NoEvents = (x, y) =>
{
/*
lock (requests)
{
Hashtable request = requests.Find(id => id["RequestID"].ToString() == x.ToString());
requests.Remove(request);
}
*/
Hashtable response = new Hashtable();
response["int_response_code"] = 500;
@ -189,24 +196,9 @@ namespace OpenSim.Region.ClientStack.Linden
};
}
public void Process()
public void Process(aPollRequest requestinfo)
{
Hashtable request = null;
try
{
lock (requests)
{
request = requests[0];
requests.RemoveAt(0);
}
}
catch
{
return;
}
UUID requestID = new UUID(request["RequestID"].ToString());
UUID requestID = requestinfo.reqID;
Hashtable response = new Hashtable();
@ -215,7 +207,8 @@ namespace OpenSim.Region.ClientStack.Linden
response["keepalive"] = false;
response["reusecontext"] = false;
response["str_response_string"] = m_webFetchHandler.FetchInventoryDescendentsRequest(request["body"].ToString(), String.Empty, String.Empty, null, null);
response["str_response_string"] = m_webFetchHandler.FetchInventoryDescendentsRequest(
requestinfo.request["body"].ToString(), String.Empty, String.Empty, null, null);
lock (responses)
responses[requestID] = response;
@ -226,8 +219,7 @@ namespace OpenSim.Region.ClientStack.Linden
{
string capUrl = "/CAPS/" + UUID.Random() + "/";
// Register this as a poll service
// absurd large timeout to tune later to make a bit less than viewer
// Register this as a poll service
PollServiceInventoryEventArgs args = new PollServiceInventoryEventArgs(agentID);
args.Type = PollServiceEventArgs.EventType.Inventory;
@ -263,9 +255,9 @@ namespace OpenSim.Region.ClientStack.Linden
{
while (true)
{
PollServiceInventoryEventArgs args = m_queue.Dequeue();
aPollRequest poolreq = m_queue.Dequeue();
args.Process();
poolreq.thepoll.Process(poolreq);
}
}
}