From 44bfc61a41bd8521a88c0061c0122a7e1fe5baed Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Wed, 13 Nov 2024 07:47:59 +0100 Subject: [PATCH] PeerMessageQueue: actually use the 10% bulk fallback --- src/freenet/node/PeerMessageQueue.java | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/freenet/node/PeerMessageQueue.java b/src/freenet/node/PeerMessageQueue.java index 9cfe72a6e4..75da9af4f9 100644 --- a/src/freenet/node/PeerMessageQueue.java +++ b/src/freenet/node/PeerMessageQueue.java @@ -876,22 +876,20 @@ public synchronized MessageItem grabQueuedMessageItem(int minPriority) { if(ret != null) return ret; } - // Include bulk or realtime, whichever is more urgent. - - boolean tryRealtimeFirst = this.fastWeakRandom.nextInt(10) > 0; - - // If one is empty, try the other. - // Otherwise try whichever is more urgent, favouring realtime if there is a draw. - // Realtime is supposed to be bursty. + + // Include bulk or realtime, whichever is more urgent. + boolean tryRealtimeFirst; if(queuesByPriority[DMT.PRIORITY_REALTIME_DATA].isEmpty()) { tryRealtimeFirst = false; } else if(queuesByPriority[DMT.PRIORITY_BULK_DATA].isEmpty()) { tryRealtimeFirst = true; - } else if(queuesByPriority[DMT.PRIORITY_BULK_DATA].getNextUrgentTime(Long.MAX_VALUE, 0) >= queuesByPriority[DMT.PRIORITY_REALTIME_DATA].getNextUrgentTime(Long.MAX_VALUE, 0)) { + } else if(queuesByPriority[DMT.PRIORITY_BULK_DATA].getNextUrgentTime(Long.MAX_VALUE, 0) + >= queuesByPriority[DMT.PRIORITY_REALTIME_DATA].getNextUrgentTime(Long.MAX_VALUE, 0)) { tryRealtimeFirst = true; } else { - tryRealtimeFirst = false; + // 10% chance to use bulk in case of a draw to avoid starving the bulk queue. + tryRealtimeFirst = this.fastWeakRandom.nextInt(10) > 0; }