Repository navigation
fix: surface EMSGSIZE as RMW_RET_ERROR on publish - #3
Merged
Merged
Conversation
rmw_publish previously discarded send_to()'s return value and always
returned RMW_RET_OK. When sendmsg() failed with EMSGSIZE (datagram
larger than the kernel-clamped SO_SNDBUF, e.g. net.core.wmem_max not
tuned), the application saw "success" while no subscriber received
anything. This was a silent data-loss bug at ~416 KB and above on a
default-configured host.
Replace send_to()'s bool return with an enum SendResult that
distinguishes ConfigError (EMSGSIZE — hard, non-transient) from
SoftDrop (EAGAIN/ENOBUFS/ENOENT/ECONNREFUSED — routine for a
non-blocking transport). rmw_publish and rmw_publish_serialized_message
now propagate ConfigError as RMW_RET_ERROR with a descriptive
RMW_SET_ERROR_MSG; SoftDrop semantics are unchanged (still logged
inside send_to, still RMW_RET_OK to the caller).
Also add a one-shot per-process check at rmw_init that warns if
/proc/sys/net/core/{wmem,rmem}_max is below the SO_{SND,RCV}BUF we
request, so the misconfiguration surfaces at startup instead of on
the first big publish.
Tests:
- PublishReturnsErrorOnEMSGSIZE: shrinks SO_SNDBUF and asserts that
rmw_publish_serialized_message returns RMW_RET_ERROR.
- PublishStillReturnsOkOnSoftDropPeerGone: unlinks a sub's socket
and asserts the next publish still returns RMW_RET_OK (ENOENT
must not be propagated).
Both fail on HEAD and pass with this change.
Owner
Author
Review: fix: surface EMSGSIZE as RMW_RET_ERROR on publishApproving. This is a clean, focused, correct fix for a real silent-data-loss bug. Verified against the PR branch ( What I checked:
Non-blocking, optional pre-merge polish:
LGTM. |
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.
Summary
rmw_publishpreviously discardedsend_to()'s return value and always returnedRMW_RET_OK. Whensendmsg()failed withEMSGSIZE— datagram larger than the kernel-clampedSO_SNDBUF, e.g. becausenet.core.wmem_maxwas at the distribution default — the application saw "success" while no subscriber received anything. Silent data-loss bug at roughly 416 KB and above on a default-configured host.Changes
send_to()'sboolreturn becomesenum class SendResult { Ok, SoftDrop, ConfigError }.EMSGSIZE→ConfigError;EAGAIN/ENOBUFS/ENOENT/ECONNREFUSED/ unknown errno →SoftDrop. Existing throttled log messages are unchanged.rmw_publishandrmw_publish_serialized_messagepropagateConfigErrorasRMW_RET_ERRORwith a descriptiveRMW_SET_ERROR_MSG. SoftDrop semantics are preserved — applications don't see exceptions for routine slow-subscriber / peer-teardown drops on a non-blocking transport.rmw_init: warn if/proc/sys/net/core/{wmem,rmem}_maxis below what we request viaSO_{SND,RCV}BUF. Surfaces the misconfiguration at startup instead of on the first big publish.Test plan
PublishReturnsErrorOnEMSGSIZE— shrinkSO_SNDBUFon the context's send socket; assertrmw_publish_serialized_messageof a 64 KB payload returnsRMW_RET_ERROR.PublishStillReturnsOkOnSoftDropPeerGone— unlink a sub's socket file under the publisher's cache; assert the nextrmw_publishstill returnsRMW_RET_OK(regression guard for over-escalating soft drops).mainand pass on this branch (verified viagit stash+ rebuild + ctest).ctestsuite: 12/12 pass.