Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
May 8, 2024

Conversation

fales1488
Copy link
Contributor

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

  • Modified the round-robin index update line in RecvPipe method to:
    if (!m_more)
        m_current = m_active > 0 ? (m_current + 1) % m_active : 0;

…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.
@drewnoakes drewnoakes merged commit 173358c into zeromq:master May 8, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants