* Changed EventQueueServer to always obey the KeepAlive setting requested by the client

* Added (very slow, O(n)) DoubleDictionary.Remove(TKey1) and DoubleDictionary.Remove(TKey2) functions

git-svn-id: http://libopenmetaverse.googlecode.com/svn/libopenmetaverse/trunk@2381 52acb1d6-8a22-11de-b505-999d5b087335
This commit is contained in:
John Hurliman
2008-12-15 21:05:50 +00:00
parent 4e791ad340
commit 94ea54bed6
2 changed files with 50 additions and 4 deletions

View File

@@ -139,7 +139,7 @@ namespace OpenMetaverse.Capabilities
context.Request.Url), Helpers.LogLevel.Info);
Stop();
context.Response.KeepAlive = false;
context.Response.KeepAlive = context.Request.KeepAlive;
return true;
}
}
@@ -148,7 +148,7 @@ namespace OpenMetaverse.Capabilities
Logger.Log(String.Format("[EventQueue] Received a request with invalid or missing LLSD at {0}, closing the connection",
context.Request.Url), Helpers.LogLevel.Warning);
context.Response.KeepAlive = false;
context.Response.KeepAlive = context.Request.KeepAlive;
context.Response.StatusCode = (int)HttpStatusCode.BadRequest;
return true;
}
@@ -213,6 +213,8 @@ namespace OpenMetaverse.Capabilities
void SendResponse(HttpListenerContext httpContext, List<EventQueueEvent> eventsToSend)
{
httpContext.Response.KeepAlive = httpContext.Request.KeepAlive;
if (eventsToSend != null)
{
OSDArray responseArray = new OSDArray(eventsToSend.Count);
@@ -235,7 +237,6 @@ namespace OpenMetaverse.Capabilities
// Serialize the events and send the response
byte[] buffer = OSDParser.SerializeLLSDXmlBytes(responseMap);
httpContext.Response.KeepAlive = true;
httpContext.Response.ContentType = "application/xml";
httpContext.Response.ContentLength64 = buffer.Length;
httpContext.Response.OutputStream.Write(buffer, 0, buffer.Length);
@@ -247,7 +248,6 @@ namespace OpenMetaverse.Capabilities
// The 502 response started as a bug in the LL event queue server implementation,
// but is now hardcoded into the protocol as the code to use for a timeout
httpContext.Response.StatusCode = (int)HttpStatusCode.BadGateway;
httpContext.Response.KeepAlive = true;
httpContext.Response.Close();
}
}

View File

@@ -76,6 +76,52 @@ namespace OpenMetaverse
}
}
public bool Remove(TKey1 key1)
{
// This is an O(n) operation!
lock (syncObject)
{
TValue value;
if (Dictionary1.TryGetValue(key1, out value))
{
foreach (KeyValuePair<TKey2, TValue> kvp in Dictionary2)
{
if (kvp.Value.Equals(value))
{
Dictionary1.Remove(key1);
Dictionary2.Remove(kvp.Key);
return true;
}
}
}
}
return false;
}
public bool Remove(TKey2 key2)
{
// This is an O(n) operation!
lock (syncObject)
{
TValue value;
if (Dictionary2.TryGetValue(key2, out value))
{
foreach (KeyValuePair<TKey1, TValue> kvp in Dictionary1)
{
if (kvp.Value.Equals(value))
{
Dictionary2.Remove(key2);
Dictionary1.Remove(kvp.Key);
return true;
}
}
}
}
return false;
}
public void Clear()
{
lock (syncObject)