From 20a8e57262d7fcc17582c8f42e87c8249585c799 Mon Sep 17 00:00:00 2001 From: Diego Date: Fri, 9 Feb 2024 14:42:06 +0100 Subject: [PATCH] wait for non-priority msg first before checking the priority queue --- libp2p/protocols/pubsub/pubsubpeer.nim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libp2p/protocols/pubsub/pubsubpeer.nim b/libp2p/protocols/pubsub/pubsubpeer.nim index 6c15a5286..23fc9fff1 100644 --- a/libp2p/protocols/pubsub/pubsubpeer.nim +++ b/libp2p/protocols/pubsub/pubsubpeer.nim @@ -372,11 +372,11 @@ proc clearSendPriorityQueue(p: PubSubPeer) = proc sendNonPriorityTask(p: PubSubPeer) {.async.} = while true: + # we send non-priority messages only if there are no pending priority messages + let msg = await p.rpcmessagequeue.nonPriorityQueue.popFirst() while p.rpcmessagequeue.sendPriorityQueue.len > 0: await p.rpcmessagequeue.sendPriorityQueue[0] p.clearSendPriorityQueue() - # we send non-priority messages only if there are no pending priority messages - let msg = await p.rpcmessagequeue.nonPriorityQueue.popFirst() when defined(libp2p_expensive_metrics): libp2p_gossipsub_non_priority_queue_size.dec(labelValues = [$p.peerId]) await p.sendMsg(msg)