* Only append ACKs to outgoing packets if one or more ACKs are successfully dequeued
* Commented out noisy CAPS debugging messages * Added a test (under packet tests for lack of a better place) to measure Environment.TickCount resolution and fail if the resolution is not consistently under a 10ms variance git-svn-id: http://libopenmetaverse.googlecode.com/svn/libopenmetaverse/trunk@2813 52acb1d6-8a22-11de-b505-999d5b087335
This commit is contained in:
@@ -152,7 +152,7 @@ namespace OpenMetaverse.Http
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.Log.Debug("CapsBase.OpenWrite(): " + ex.Message);
|
||||
//Logger.Log.Debug("CapsBase.OpenWrite(): " + ex.Message);
|
||||
if (state.CompletedCallback != null)
|
||||
state.CompletedCallback(state.Request, null, null, ex);
|
||||
}
|
||||
@@ -218,7 +218,7 @@ namespace OpenMetaverse.Http
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.Log.Debug("CapsBase.GetResponse(): " + ex.Message);
|
||||
//Logger.Log.Debug("CapsBase.GetResponse(): " + ex.Message);
|
||||
error = ex;
|
||||
}
|
||||
|
||||
@@ -231,8 +231,8 @@ namespace OpenMetaverse.Http
|
||||
if (timedOut)
|
||||
{
|
||||
RequestState requestState = state as RequestState;
|
||||
Logger.Log.Warn("CapsBase.TimeoutCallback(): Request to " + requestState.Request.RequestUri +
|
||||
" timed out after " + requestState.MillisecondsTimeout + " milliseconds");
|
||||
//Logger.Log.Debug("CapsBase.TimeoutCallback(): Request to " + requestState.Request.RequestUri +
|
||||
// " timed out after " + requestState.MillisecondsTimeout + " milliseconds");
|
||||
if (requestState != null && requestState.Request != null)
|
||||
requestState.Request.Abort();
|
||||
}
|
||||
|
||||
@@ -158,7 +158,7 @@ namespace OpenMetaverse.Http
|
||||
this.response = response;
|
||||
|
||||
// Spawn a new thread to hold the connection open and return from our precious IOCP thread
|
||||
Thread thread = new Thread(new ThreadStart(EventQueueThread));
|
||||
Thread thread = new Thread(EventQueueThread);
|
||||
thread.IsBackground = true;
|
||||
thread.Start();
|
||||
}
|
||||
@@ -215,10 +215,6 @@ namespace OpenMetaverse.Http
|
||||
batchMsPassed = (int)(DateTime.Now - start).TotalMilliseconds;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger.Log.Info("[EventQueue] Dequeued a signal to close the handler thread");
|
||||
}
|
||||
|
||||
// Make sure we can actually send the events right now
|
||||
if (context.Stream == null || !context.Stream.CanWrite)
|
||||
|
||||
@@ -155,5 +155,31 @@ namespace OpenMetaverse.Tests
|
||||
Assert.IsTrue(queryRepliesCount == bigPacket.QueryData.Length);
|
||||
Assert.IsTrue(statusDataCount == bigPacket.StatusData.Length);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TickCountResolution()
|
||||
{
|
||||
float minResolution = Single.MaxValue;
|
||||
float maxResolution = Single.MinValue;
|
||||
|
||||
// Measure the resolution of Environment.TickCount
|
||||
float tickCountResolution = 0f;
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
int start = Environment.TickCount;
|
||||
int now = start;
|
||||
while (now == start)
|
||||
now = Environment.TickCount;
|
||||
|
||||
float resolution = (float)(now - start);
|
||||
tickCountResolution += tickCountResolution * 0.1f;
|
||||
minResolution = Math.Min(minResolution, resolution);
|
||||
maxResolution = Math.Max(maxResolution, resolution);
|
||||
}
|
||||
|
||||
Console.WriteLine("Average Environment.TickCount resolution: " + tickCountResolution + "ms");
|
||||
Assert.Less(maxResolution - minResolution, 10f, "Environment.TickCount resolution fluctuated between " +
|
||||
minResolution + "ms and " + maxResolution + "ms");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -743,12 +743,17 @@ namespace OpenMetaverse
|
||||
dataLength += 4;
|
||||
++ackCount;
|
||||
}
|
||||
buffer.Data[dataLength++] = (byte)ackCount;
|
||||
|
||||
if (ackCount > 0)
|
||||
{
|
||||
// Set the last byte of the packet equal to the number of appended ACKs
|
||||
buffer.Data[dataLength++] = (byte)ackCount;
|
||||
// Set the appended ACKs flag on this packet
|
||||
buffer.Data[0] = (byte)(buffer.Data[0] | Helpers.MSG_APPENDED_ACKS);
|
||||
}
|
||||
|
||||
buffer.DataLength = dataLength;
|
||||
|
||||
// Set the appended ACKs flag on this packet
|
||||
buffer.Data[0] = (byte)(buffer.Data[0] | Helpers.MSG_APPENDED_ACKS);
|
||||
|
||||
#endregion ACK Appending
|
||||
|
||||
// Add this packet to the list of ACK responses we are waiting on from the server
|
||||
|
||||
Reference in New Issue
Block a user