]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Made FewToFewBiQueue::peek() check both incoming and outgoing queues
authorAlex Rousskov <rousskov@measurement-factory.com>
Mon, 29 Aug 2011 20:58:29 +0000 (14:58 -0600)
committerAlex Rousskov <rousskov@measurement-factory.com>
Mon, 29 Aug 2011 20:58:29 +0000 (14:58 -0600)
to find the oldest queued value. This may help when the delay is on
our side (i.e., we are not receiving or processing completed I/Os fast enough).

src/ipc/Queue.h

index 94a98f758e43bbf985f813c62252139651004c8e..c211031fecef24c56a4179e0efcd96ebf006dd24 100644 (file)
@@ -328,9 +328,16 @@ FewToFewBiQueue::peek(const int remoteProcessId, Value &value) const
     if (!validProcessId(remoteGroup(), remoteProcessId))
         return false;
 
-    const OneToOneUniQueue &remoteQueue = oneToOneQueue(theLocalGroup, theLocalProcessId, remoteGroup(), remoteProcessId);
-    debugs(54, 7, HERE << "peeking from " << theLocalProcessId << " to " << remoteProcessId << " at " << remoteQueue.size());
-    return remoteQueue.peek(value);
+    // we need the oldest value, so start with the incoming, them-to-us queue:
+    const OneToOneUniQueue &inQueue = oneToOneQueue(remoteGroup(), remoteProcessId, theLocalGroup, theLocalProcessId);
+    debugs(54, 2, HERE << "peeking from " << remoteProcessId << " to " << theLocalProcessId << " at " << inQueue.size());
+    if (inQueue.peek(value))
+        return true;
+
+    // if the incoming queue is empty, check the outgoing, us-to-them queue:
+    const OneToOneUniQueue &outQueue = oneToOneQueue(theLocalGroup, theLocalProcessId, remoteGroup(), remoteProcessId);
+    debugs(54, 2, HERE << "peeking from " << theLocalProcessId << " to " << remoteProcessId << " at " << outQueue.size());
+    return outQueue.peek(value);
 }
 
 } // namespace Ipc