delta recursion protection

flush in send completion
This commit is contained in:
Mark Sturgill 2013-10-12 15:53:29 -07:00
parent 2cac2c55d2
commit 41019b691b
4 changed files with 56 additions and 17 deletions

View file

@ -3039,9 +3039,17 @@ namespace Server
{
SetFlag( ImplFlag.InQueue, true );
if (_processing)
Console.WriteLine(new System.Diagnostics.StackTrace());
m_DeltaQueue.Add( this );
if (_processing) {
try {
using (StreamWriter op = new StreamWriter("delta-recursion.log", true)) {
op.WriteLine("# {0}", DateTime.UtcNow);
op.WriteLine(new System.Diagnostics.StackTrace());
op.WriteLine();
}
} catch { }
} else {
m_DeltaQueue.Add(this);
}
}
Core.Set();
@ -3055,9 +3063,17 @@ namespace Server
{
SetFlag( ImplFlag.InQueue, false );
if (_processing)
Console.WriteLine(new System.Diagnostics.StackTrace());
m_DeltaQueue.Remove( this );
if (_processing) {
try {
using (StreamWriter op = new StreamWriter("delta-recursion.log", true)) {
op.WriteLine("# {0}", DateTime.UtcNow);
op.WriteLine(new System.Diagnostics.StackTrace());
op.WriteLine();
}
} catch { }
} else {
m_DeltaQueue.Remove( this );
}
}
}

View file

@ -10005,6 +10005,7 @@ namespace Server
}
private static Queue<Mobile> m_DeltaQueue = new Queue<Mobile>();
private static Queue<Mobile> m_DeltaQueueR = new Queue<Mobile>();
private bool m_InDeltaQueue;
private MobileDelta m_DeltaFlags;
@ -10020,9 +10021,21 @@ namespace Server
{
m_InDeltaQueue = true;
if (_processing)
Console.WriteLine(new System.Diagnostics.StackTrace());
m_DeltaQueue.Enqueue( this );
if (_processing) {
lock (m_DeltaQueueR) {
m_DeltaQueueR.Enqueue(this);
try {
using (StreamWriter op = new StreamWriter("delta-recursion.log", true)) {
op.WriteLine("# {0}", DateTime.UtcNow);
op.WriteLine(new System.Diagnostics.StackTrace());
op.WriteLine();
}
} catch { }
}
} else {
m_DeltaQueue.Enqueue( this );
}
}
Core.Set();
@ -10524,7 +10537,7 @@ namespace Server
}
}
public static bool _processing = false;
private static bool _processing = false;
public static void ProcessDeltaQueue()
{
@ -10533,6 +10546,8 @@ namespace Server
Parallel.ForEach( m_DeltaQueue, m => m.ProcessDelta() );
m_DeltaQueue.Clear();
_processing = false;
Parallel.ForEach( m_DeltaQueueR, m => m.ProcessDelta() );
m_DeltaQueueR.Clear();
#else
int count = m_DeltaQueue.Count;
int index = 0;

View file

@ -220,13 +220,15 @@ namespace Server.Network
}
if ( length >= packetLength ) {
if ( handler.Ingame && ns.Mobile == null ) {
Console.WriteLine( "Client: {0}: Sent ingame packet (0x{1:X2}) before having been attached to a mobile", ns, packetID );
ns.Dispose();
break;
} else if ( handler.Ingame && ns.Mobile.Deleted ) {
ns.Dispose();
break;
if (handler.Ingame) {
if (ns.Mobile == null ) {
Console.WriteLine( "Client: {0}: Sent ingame packet (0x{1:X2}) before having been attached to a mobile", ns, packetID );
ns.Dispose();
break;
} else if (ns.Mobile.Deleted) {
ns.Dispose();
break;
}
}
ThrottlePacketCallback throttler = handler.ThrottleCallback;

View file

@ -772,6 +772,9 @@ namespace Server.Network {
lock ( m_SendQueue ) {
gram = m_SendQueue.Dequeue();
if (gram == null && m_SendQueue.IsFlushReady)
gram = m_SendQueue.CheckFlushReady();
}
if ( gram != null ) {
@ -943,6 +946,9 @@ namespace Server.Network {
lock (m_SendQueue) {
gram = m_SendQueue.Dequeue();
if (gram == null && m_SendQueue.IsFlushReady)
gram = m_SendQueue.CheckFlushReady();
}
if (gram != null) {