Skip to content

Commit

Permalink
Prevent division by zero in FairQueueing when no active pipes are ava…
Browse files Browse the repository at this point in the history
…ilable

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.
  • Loading branch information
fales1488 authored May 7, 2024
1 parent 97da3b4 commit 2ce70f0
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/NetMQ/Core/Patterns/Utils/FairQueueing.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public bool RecvPipe(ref Msg msg, [NotNullWhen(returnValue: true)] out Pipe? pip

m_more = msg.HasMore;
if (!m_more)
m_current = (m_current + 1) % m_active;
m_current = m_active > 0 ? (m_current + 1) % m_active : 0;
return true;
}

Expand Down

0 comments on commit 2ce70f0

Please sign in to comment.