Skip to content

Commit 2ce70f0

Browse files
Prevent division by zero in FairQueueing when no active pipes are available
This commit fixes a potential DivideByZeroException in the FairQueueing class by conditionally performing the modulo operation only when there are active pipes (m_active > 0). This issue occurs during round-robin processing of messages when all pipes have been deactivated. The modification ensures stability and prevents crashes under these specific conditions.
1 parent 97da3b4 commit 2ce70f0

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/NetMQ/Core/Patterns/Utils/FairQueueing.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ public bool RecvPipe(ref Msg msg, [NotNullWhen(returnValue: true)] out Pipe? pip
122122

123123
m_more = msg.HasMore;
124124
if (!m_more)
125-
m_current = (m_current + 1) % m_active;
125+
m_current = m_active > 0 ? (m_current + 1) % m_active : 0;
126126
return true;
127127
}
128128

0 commit comments

Comments
 (0)