* Event queue is now polling..
* returns FAKEEVENT instead of the connection returning a 502. It doesn't like our 502's for some reason.. so, in leau of this.. send it a fake event. * Once again, this is still 'really early' code, so please don't blame us if you have no more threads left.0.6.0-stable
parent
0e10c85617
commit
98632ee594
|
@ -991,6 +991,7 @@ namespace OpenSim.Framework.Servers
|
||||||
string responseString = (string)responsedata["str_response_string"];
|
string responseString = (string)responsedata["str_response_string"];
|
||||||
string contentType = (string)responsedata["content_type"];
|
string contentType = (string)responsedata["content_type"];
|
||||||
|
|
||||||
|
|
||||||
if (responsedata.ContainsKey("keepalive"))
|
if (responsedata.ContainsKey("keepalive"))
|
||||||
response.KeepAlive = true;
|
response.KeepAlive = true;
|
||||||
|
|
||||||
|
@ -1042,6 +1043,7 @@ namespace OpenSim.Framework.Servers
|
||||||
{
|
{
|
||||||
response.OutputStream.Close();
|
response.OutputStream.Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SendHTML404(OSHttpResponse response, string host)
|
public void SendHTML404(OSHttpResponse response, string host)
|
||||||
|
|
|
@ -783,7 +783,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||||
ClientLoop();
|
ClientLoop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (System.Exception e)
|
//Todo set as Generic Exception again.
|
||||||
|
catch (System.BadImageFormatException e)
|
||||||
{
|
{
|
||||||
if (e is ThreadAbortException)
|
if (e is ThreadAbortException)
|
||||||
throw e;
|
throw e;
|
||||||
|
|
|
@ -52,12 +52,20 @@ using BlockingLLSDQueue = OpenSim.Framework.BlockingQueue<OpenMetaverse.Structur
|
||||||
|
|
||||||
namespace OpenSim.Region.Environment.Modules.Framework
|
namespace OpenSim.Region.Environment.Modules.Framework
|
||||||
{
|
{
|
||||||
|
public struct QueueItem
|
||||||
|
{
|
||||||
|
public int id;
|
||||||
|
public LLSDMap body;
|
||||||
|
}
|
||||||
|
|
||||||
public class EventQueueGetModule : IEventQueue, IRegionModule
|
public class EventQueueGetModule : IEventQueue, IRegionModule
|
||||||
{
|
{
|
||||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
private Scene m_scene = null;
|
private Scene m_scene = null;
|
||||||
private IConfigSource m_gConfig;
|
private IConfigSource m_gConfig;
|
||||||
|
|
||||||
|
private Dictionary<UUID, int> m_ids = new Dictionary<UUID, int>();
|
||||||
|
|
||||||
private Dictionary<UUID, BlockingLLSDQueue> queues = new Dictionary<UUID, BlockingLLSDQueue>();
|
private Dictionary<UUID, BlockingLLSDQueue> queues = new Dictionary<UUID, BlockingLLSDQueue>();
|
||||||
|
|
||||||
#region IRegionModule methods
|
#region IRegionModule methods
|
||||||
|
@ -83,6 +91,7 @@ namespace OpenSim.Region.Environment.Modules.Framework
|
||||||
|
|
||||||
private void ReadConfigAndPopulate(Scene scene, IConfig startupConfig, string p)
|
private void ReadConfigAndPopulate(Scene scene, IConfig startupConfig, string p)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void PostInitialise()
|
public void PostInitialise()
|
||||||
|
@ -147,6 +156,7 @@ namespace OpenSim.Region.Environment.Modules.Framework
|
||||||
{
|
{
|
||||||
m_log.DebugFormat("[EVENTQUEUE]: Avatar {0} entering parcel {1} in region {2}.",
|
m_log.DebugFormat("[EVENTQUEUE]: Avatar {0} entering parcel {1} in region {2}.",
|
||||||
avatar.UUID, localLandID, regionID);
|
avatar.UUID, localLandID, regionID);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void MakeChildAgent(ScenePresence avatar)
|
private void MakeChildAgent(ScenePresence avatar)
|
||||||
|
@ -164,29 +174,64 @@ namespace OpenSim.Region.Environment.Modules.Framework
|
||||||
{
|
{
|
||||||
return ProcessQueue(m_dhttpMethod,agentID, caps);
|
return ProcessQueue(m_dhttpMethod,agentID, caps);
|
||||||
}));
|
}));
|
||||||
|
Random rnd = new Random(System.Environment.TickCount);
|
||||||
|
lock (m_ids)
|
||||||
|
{
|
||||||
|
if (!m_ids.ContainsKey(agentID))
|
||||||
|
m_ids.Add(agentID, rnd.Next(30000000));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Hashtable ProcessQueue(Hashtable request,UUID agentID, Caps caps)
|
public Hashtable ProcessQueue(Hashtable request,UUID agentID, Caps caps)
|
||||||
{
|
{
|
||||||
// TODO: this has to be redone to not busy-wait (and block the thread),
|
// TODO: this has to be redone to not busy-wait (and block the thread),
|
||||||
// TODO: as soon as we have a non-blocking way to handle HTTP-requests.
|
// TODO: as soon as we have a non-blocking way to handle HTTP-requests.
|
||||||
|
|
||||||
BlockingLLSDQueue queue = GetQueue(agentID);
|
BlockingLLSDQueue queue = GetQueue(agentID);
|
||||||
LLSD element = queue.Dequeue(15000); // 15s timeout
|
LLSD element = queue.Dequeue(15000); // 15s timeout
|
||||||
|
|
||||||
|
|
||||||
String debug = "[EVENTQUEUE]: Got request for agent {0}: [ ";
|
String debug = "[EVENTQUEUE]: Got request for agent {0}: [ ";
|
||||||
foreach(object key in request.Keys)
|
foreach(object key in request.Keys)
|
||||||
{
|
{
|
||||||
debug += key.ToString() + "=" + request[key].ToString() + " ";
|
debug += key.ToString() + "=" + request[key].ToString() + " ";
|
||||||
}
|
}
|
||||||
m_log.DebugFormat(debug, agentID);
|
//m_log.DebugFormat(debug, agentID);
|
||||||
|
|
||||||
if (element == null) // didn't have an event in 15s
|
if (element == null) // didn't have an event in 15s
|
||||||
{
|
{
|
||||||
|
// Send it a fake event to keep the client polling! It doesn't like 502s like the proxys say!
|
||||||
|
element = EventQueueHelper.KeepAliveEvent();
|
||||||
|
|
||||||
|
ScenePresence avatar;
|
||||||
|
m_scene.TryGetAvatar(agentID, out avatar);
|
||||||
|
|
||||||
|
LLSDArray array = new LLSDArray();
|
||||||
|
array.Add(element);
|
||||||
|
int thisID = m_ids[agentID];
|
||||||
|
while (queue.Count() > 0)
|
||||||
|
{
|
||||||
|
array.Add(queue.Dequeue(1));
|
||||||
|
thisID++;
|
||||||
|
}
|
||||||
|
LLSDMap events = new LLSDMap();
|
||||||
|
events.Add("events", array);
|
||||||
|
|
||||||
|
events.Add("id", new LLSDInteger(thisID));
|
||||||
|
lock (m_ids)
|
||||||
|
{
|
||||||
|
m_ids[agentID] = thisID + 1;
|
||||||
|
}
|
||||||
Hashtable responsedata = new Hashtable();
|
Hashtable responsedata = new Hashtable();
|
||||||
responsedata["int_response_code"] = 502;
|
responsedata["int_response_code"] = 200;
|
||||||
responsedata["str_response_string"] = "Upstream error:";
|
responsedata["content_type"] = "application/llsd+xml";
|
||||||
responsedata["content_type"] = "text/plain";
|
|
||||||
responsedata["keepalive"] = true;
|
responsedata["keepalive"] = true;
|
||||||
|
responsedata["str_response_string"] = LLSDParser.SerializeXmlString(events);
|
||||||
|
//m_log.DebugFormat("[EVENTQUEUE]: sending fake response for {0}: {1}", agentID, responsedata["str_response_string"]);
|
||||||
|
|
||||||
return responsedata;
|
return responsedata;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -196,14 +241,20 @@ namespace OpenSim.Region.Environment.Modules.Framework
|
||||||
|
|
||||||
LLSDArray array = new LLSDArray();
|
LLSDArray array = new LLSDArray();
|
||||||
array.Add(element);
|
array.Add(element);
|
||||||
|
int thisID = m_ids[agentID];
|
||||||
while (queue.Count() > 0)
|
while (queue.Count() > 0)
|
||||||
{
|
{
|
||||||
array.Add(queue.Dequeue(1));
|
array.Add(queue.Dequeue(1));
|
||||||
|
thisID++;
|
||||||
}
|
}
|
||||||
LLSDMap events = new LLSDMap();
|
LLSDMap events = new LLSDMap();
|
||||||
events.Add("events", array);
|
events.Add("events", array);
|
||||||
events.Add("id", new LLSDInteger(1)); // TODO: this seems to be a event sequence-numeber to be ack'd by the client?
|
|
||||||
|
|
||||||
|
events.Add("id", new LLSDInteger(thisID));
|
||||||
|
lock (m_ids)
|
||||||
|
{
|
||||||
|
m_ids[agentID] = thisID + 1;
|
||||||
|
}
|
||||||
Hashtable responsedata = new Hashtable();
|
Hashtable responsedata = new Hashtable();
|
||||||
responsedata["int_response_code"] = 200;
|
responsedata["int_response_code"] = 200;
|
||||||
responsedata["content_type"] = "application/llsd+xml";
|
responsedata["content_type"] = "application/llsd+xml";
|
||||||
|
|
|
@ -53,6 +53,15 @@ namespace OpenSim.Region.Environment
|
||||||
llsdMessage.Add("message", new LLSDString("EnableSimulator"));
|
llsdMessage.Add("message", new LLSDString("EnableSimulator"));
|
||||||
llsdMessage.Add("body", llsdBody);
|
llsdMessage.Add("body", llsdBody);
|
||||||
|
|
||||||
|
return llsdMessage;
|
||||||
|
}
|
||||||
|
public static LLSD KeepAliveEvent()
|
||||||
|
{
|
||||||
|
LLSDMap llsdSimInfo = new LLSDMap();
|
||||||
|
LLSDMap llsdMessage = new LLSDMap(2);
|
||||||
|
llsdMessage.Add("message", new LLSDString("FAKEEVENT"));
|
||||||
|
llsdMessage.Add("body", llsdSimInfo);
|
||||||
|
|
||||||
return llsdMessage;
|
return llsdMessage;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue