Fix broker disconnect to better handle SIGPIPE#548
Merged
Conversation
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #548
Scan targets checked: wolfmqtt-bugs, wolfmqtt-src
Findings: 3
3 finding(s) posted as inline comments (see file-level comments below)
This review was generated automatically by Fenrir. Findings are non-blocking.
There was a problem hiding this comment.
Pull request overview
This PR addresses a broker crash caused by SIGPIPE when writing responses (e.g., PUBREC) to a socket that the peer has already closed, and adds regression coverage around the QoS 2 state-machine path involved in the reported scenario.
Changes:
- Suppress SIGPIPE in the broker POSIX network layer using
MSG_NOSIGNAL(where available) andSO_NOSIGPIPE(macOS/BSD). - Add new broker unit tests that exercise QoS 2 publish + immediate disconnect / abrupt close with an offline durable subscriber.
- Ignore newly built broker test executables in
.gitignore.
Reviewed changes
Copilot reviewed 2 out of 3 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
src/mqtt_broker.c |
Adds SIGPIPE suppression for broker socket writes (MSG_NOSIGNAL / SO_NOSIGPIPE) and installs SIGPIPE ignore in initialization paths. |
tests/test_broker_connect.c |
Extends mock networking to simulate read errors and adds new QoS 2 regression tests for disconnect/abrupt-close scenarios. |
.gitignore |
Ignores broker/unit test binaries. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
embhorn
approved these changes
Jun 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.