some changes on pollevent

httptests
UbitUmarov 2017-06-06 21:55:47 +01:00
parent 8971e9f126
commit 7d58b73bbc
4 changed files with 49 additions and 75 deletions

View File

@ -1935,20 +1935,13 @@ namespace OpenSim.Framework.Servers.HttpServer
{
response.ProtocolVersion = (string)responsedata["http_protocol_version"];
}
/*
if (responsedata.ContainsKey("keepalive"))
{
bool keepalive = (bool)responsedata["keepalive"];
response.KeepAlive = keepalive;
}
if (responsedata.ContainsKey("reusecontext"))
response.ReuseContext = (bool) responsedata["reusecontext"];
*/
// disable this things
response.KeepAlive = false;
// response.ReuseContext = false;
// Cross-Origin Resource Sharing with simple requests
if (responsedata.ContainsKey("access_control_allow_origin"))
response.AddHeader("Access-Control-Allow-Origin", (string)responsedata["access_control_allow_origin"]);
@ -1961,11 +1954,8 @@ namespace OpenSim.Framework.Servers.HttpServer
contentType = "text/html";
}
// The client ignores anything but 200 here for web login, so ensure that this is 200 for that
response.StatusCode = responsecode;
if (responsecode == (int)OSHttpStatusCode.RedirectMovedPermanently)
@ -1975,7 +1965,6 @@ namespace OpenSim.Framework.Servers.HttpServer
}
response.AddHeader("Content-Type", contentType);
if (responsedata.ContainsKey("headers"))
{
Hashtable headerdata = (Hashtable)responsedata["headers"];

View File

@ -271,22 +271,17 @@ namespace OpenSim.Framework.Servers.HttpServer
if (req.PollServiceArgs.HasEvents(req.RequestID, req.PollServiceArgs.Id))
{
Hashtable responsedata = req.PollServiceArgs.GetEvents(req.RequestID, req.PollServiceArgs.Id);
m_threadPool.QueueWorkItem(x =>
{
try
{
Hashtable responsedata = req.PollServiceArgs.GetEvents(req.RequestID, req.PollServiceArgs.Id);
req.DoHTTPGruntWork(m_server, responsedata);
}
catch (ObjectDisposedException) { }
finally
{
if(req.HttpContext.CanSend() && req.PollServiceArgs.Type == PollServiceEventArgs.EventType.Poll
&& (Environment.TickCount - req.RequestTime) > req.PollServiceArgs.TimeOutms)
ReQueueEvent(req);
else
byContextDequeue(req);
byContextDequeue(req);
}
return null;
}, null);

View File

@ -30,7 +30,7 @@ using System.Collections;
using System.Collections.Generic;
using System.Net;
using System.Reflection;
using System.Threading;
using System.Text;
using log4net;
using Nini.Config;
using Mono.Addins;
@ -292,8 +292,6 @@ namespace OpenSim.Region.ClientStack.Linden
Queue<OSD> queue;
Random rnd = new Random(Environment.TickCount);
int nrnd = rnd.Next(30000000);
if (nrnd < 0)
nrnd = -nrnd;
lock (queues)
{
@ -307,21 +305,11 @@ namespace OpenSim.Region.ClientStack.Linden
queue = new Queue<OSD>();
queues[agentID] = queue;
// push markers to handle old responses still waiting
// this will cost at most viewer getting two forced noevents
// even being a new queue better be safe
queue.Enqueue(null);
queue.Enqueue(null); // one should be enough
lock (m_AvatarQueueUUIDMapping)
{
eventQueueGetUUID = UUID.Random();
if (m_AvatarQueueUUIDMapping.ContainsKey(agentID))
{
// oops this should not happen ?
m_log.DebugFormat("[EVENTQUEUE]: Found Existing UUID without a queue");
eventQueueGetUUID = m_AvatarQueueUUIDMapping[agentID];
}
while(m_AvatarQueueUUIDMapping.ContainsKey(agentID))
eventQueueGetUUID = UUID.Random();
m_AvatarQueueUUIDMapping.Add(agentID, eventQueueGetUUID);
}
lock (m_ids)
@ -329,18 +317,14 @@ namespace OpenSim.Region.ClientStack.Linden
if (!m_ids.ContainsKey(agentID))
m_ids.Add(agentID, nrnd);
else
m_ids[agentID] = nrnd;
m_ids[agentID]++;
}
}
else
{
// push markers to handle old responses still waiting
// this will cost at most viewer getting two forced noevents
// even being a new queue better be safe
queue.Enqueue(null);
queue.Enqueue(null); // one should be enough
// reuse or not to reuse TODO FIX
// reuse or not to reuse
lock (m_AvatarQueueUUIDMapping)
{
// Reuse open queues. The client does!
@ -349,29 +333,38 @@ namespace OpenSim.Region.ClientStack.Linden
{
m_log.DebugFormat("[EVENTQUEUE]: Found Existing UUID!");
eventQueueGetUUID = m_AvatarQueueUUIDMapping[agentID];
lock (m_ids)
{
// change to negative numbers so they are changed at end of sending first marker
// old data on a queue may be sent on a response for a new caps
// but at least will be sent with coerent IDs
if (!m_ids.ContainsKey(agentID))
m_ids.Add(agentID, -nrnd); // should not happen
else
m_ids[agentID] = -m_ids[agentID];
}
}
else
{
eventQueueGetUUID = UUID.Random();
while(m_AvatarQueueUUIDMapping.ContainsKey(agentID))
eventQueueGetUUID = UUID.Random();
m_AvatarQueueUUIDMapping.Add(agentID, eventQueueGetUUID);
m_log.DebugFormat("[EVENTQUEUE]: Using random UUID!");
lock (m_ids)
{
if (!m_ids.ContainsKey(agentID))
m_ids.Add(agentID, nrnd);
else
m_ids[agentID]++;
}
}
}
lock (m_ids)
{
// change to negative numbers so they are changed at end of sending first marker
// old data on a queue may be sent on a response for a new caps
// but at least will be sent with coerent IDs
if (!m_ids.ContainsKey(agentID))
m_ids.Add(agentID, -nrnd); // should not happen
else
m_ids[agentID] = -m_ids[agentID];
}
}
}
caps.RegisterPollHandler(
"EventQueueGet",
caps.RegisterPollHandler(
"EventQueueGet",
new PollServiceEventArgs(null, GenerateEqgCapPath(eventQueueGetUUID), HasEvents, GetEvents, NoEvents, Drop, agentID, SERVER_EQ_TIME_NO_EVENTS));
}
@ -448,7 +441,6 @@ namespace OpenSim.Region.ClientStack.Linden
if (DebugLevel > 0)
LogOutboundDebugMessage(element, pAgentId);
array.Add(element);
thisID++;
}
}
@ -465,8 +457,6 @@ namespace OpenSim.Region.ClientStack.Linden
{
Random rnd = new Random(Environment.TickCount);
thisID = rnd.Next(30000000);
if (thisID < 0)
thisID = -thisID;
}
lock (m_ids)
@ -474,16 +464,19 @@ namespace OpenSim.Region.ClientStack.Linden
m_ids[pAgentId] = thisID + 1;
}
Hashtable responsedata;
// if there where no elements before a marker send a NoEvents
if (array.Count == 0)
return NoEvents(requestID, pAgentId);
Hashtable responsedata = new Hashtable();
responsedata["int_response_code"] = 200;
responsedata["content_type"] = "application/xml";
responsedata["keepalive"] = false;
responsedata["reusecontext"] = false;
responsedata["str_response_string"] = OSDParser.SerializeLLSDXmlString(events);
if (events == null)
{
return NoEvents(requestID, pAgentId);
}
else
{
responsedata = new Hashtable();
responsedata["int_response_code"] = 200;
responsedata["content_type"] = "application/xml";
responsedata["bin_response_data"] = Encoding.UTF8.GetBytes(OSDParser.SerializeLLSDXmlString(events));
}
//m_log.DebugFormat("[EVENTQUEUE]: sending response for {0} in region {1}: {2}", pAgentId, m_scene.RegionInfo.RegionName, responsedata["str_response_string"]);
return responsedata;
}
@ -493,13 +486,13 @@ namespace OpenSim.Region.ClientStack.Linden
Hashtable responsedata = new Hashtable();
responsedata["int_response_code"] = 502;
responsedata["content_type"] = "text/plain";
responsedata["keepalive"] = false;
responsedata["reusecontext"] = false;
responsedata["str_response_string"] = "<llsd></llsd>";
responsedata["error_status_text"] = "<llsd></llsd>";
responsedata["http_protocol_version"] = "HTTP/1.0";
responsedata["keepalive"] = false;
return responsedata;
}
/* this is not a event message
public void DisableSimulator(ulong handle, UUID avatarID)
{

View File

@ -1719,26 +1719,23 @@ namespace OpenSim.Region.CoreModules.World.Land
private void EventManagerOnRegisterCaps(UUID agentID, Caps caps)
{
//string capsBase = "/CAPS/" + UUID.Random();
string capsBase = "/CAPS/" + caps.CapsObjectPath;
string cap = "/CAPS/" + UUID.Random();
caps.RegisterHandler(
"RemoteParcelRequest",
new RestStreamHandler(
"POST",
capsBase,
"POST", cap,
(request, path, param, httpRequest, httpResponse)
=> RemoteParcelRequest(request, path, param, agentID, caps),
"RemoteParcelRequest",
agentID.ToString()));
UUID parcelCapID = UUID.Random();
cap = "/CAPS/" + UUID.Random();
caps.RegisterHandler(
"ParcelPropertiesUpdate",
new RestStreamHandler(
"POST",
"/CAPS/" + parcelCapID,
(request, path, param, httpRequest, httpResponse)
=> ProcessPropertiesUpdate(request, path, param, agentID, caps),
"POST", cap,
(request, path, param, httpRequest, httpResponse)
=> ProcessPropertiesUpdate(request, path, param, agentID, caps),
"ParcelPropertiesUpdate",
agentID.ToString()));
}