Skip to content

failed handshake decrements the connected-clients stat #175

Description

@fabracht

Found in the PR #170 review.

Defect: impl Drop for ClientHandler (client_handler/mod.rs) calls stats.client_disconnected() whenever client_id is set. That includes handshakes that failed and never called client_connected().

Effect:

  • In debug builds, the next connection's handler panics with "attempt to add with overflow" (sys_topics.rs) after its CONNACK, which kills that connection.
  • In release builds, the $SYS connected-clients count wraps around.

Fix: decrement only if this handler incremented the count, for example with a flag set when client_connected() runs.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions