Commit 04d3ab0a authored by Marc Gravell's avatar Marc Gravell

Tweak name from `PeekPing` to `DequeueUnsentPing`, to better reflect what it...

Tweak name from `PeekPing` to `DequeueUnsentPing`, to better reflect what it is doing; fix the remaining count accordingly
parent 03060353
...@@ -27,20 +27,25 @@ public Message Dequeue() ...@@ -27,20 +27,25 @@ public Message Dequeue()
return null; return null;
} }
public Message PeekPing(out int queueLength) /// <summary>
/// Checks both high-pri and regular queues to see if the next item is a PING, and if so: dequeues it and returns it
/// </summary>
public Message DequeueUnsentPing(out int queueLength)
{ {
lock (regular) lock (regular)
{ {
Message peeked; Message peeked;
queueLength = high.Count + regular.Count; queueLength = high.Count + regular.Count;
//In a disconnect scenario, we don't want to complete the Ping message twice,
//dequeue it now so it wont get dequeued in AbortUnsent (if we're going down that code path)
if (high.Count != 0 && (peeked = high.Peek()).Command == RedisCommand.PING) if (high.Count != 0 && (peeked = high.Peek()).Command == RedisCommand.PING)
{ {
//In a disconnect scenario, we don't want to complete the Ping message twice, queueLength--;
//dequeue it now so it wont get dequeued in AbortUnsent (if we're going down that code path)
return high.Dequeue(); return high.Dequeue();
} }
if (regular.Count != 0 && (peeked = regular.Peek()).Command == RedisCommand.PING) if (regular.Count != 0 && (peeked = regular.Peek()).Command == RedisCommand.PING)
{ {
queueLength--;
return regular.Dequeue(); return regular.Dequeue();
} }
} }
......
...@@ -316,7 +316,7 @@ internal void OnDisconnected(ConnectionFailureType failureType, PhysicalConnecti ...@@ -316,7 +316,7 @@ internal void OnDisconnected(ConnectionFailureType failureType, PhysicalConnecti
// if the next thing in the pipe is a PING, we can tell it that we failed (this really helps spot doomed connects) // if the next thing in the pipe is a PING, we can tell it that we failed (this really helps spot doomed connects)
int count; int count;
var ping = queue.PeekPing(out count); var ping = queue.DequeueUnsentPing(out count);
if (ping != null) if (ping != null)
{ {
Trace("Marking PING as failed (queue length: " + count + ")"); Trace("Marking PING as failed (queue length: " + count + ")");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment