zeromq / netmq

A 100% native C# implementation of ZeroMQ for .NET
Other
2.93k stars 744 forks source link

Fix Division by Zero in FairQueueing when m_active is 0 #1089

Closed fales1488 closed 2 months ago

fales1488 commented 2 months ago

Problem

As detailed in issue #1088, the FairQueueing class in NetMQ is prone to a DivideByZeroException when all inbound pipes are deactivated and m_active becomes zero. This issue occurs during the round-robin selection process in the RecvPipe method.

Solution

This pull request implements a conditional check to ensure that the modulo operation for round-robin scheduling is only performed when there is at least one active pipe (m_active > 0). This change prevents the system from attempting a division by zero, which can lead to an application crash under specific scenarios.

Changes Made