Skip to content

Fix FluxRefCount(Grace) leaking the upstream when cancelled early - #4440

Open
chemicL wants to merge 2 commits into
3.8.xfrom
4289-refcount-cancel-fix
Open

chemicL wants to merge 2 commits into
3.8.xfrom
4289-refcount-cancel-fix

Conversation

@chemicL

@chemicL chemicL commented Oct 19, 2026

Copy link
Copy Markdown
Member

A subscriber cancelling before setRefCountMonitor/setRefConnection had marked the monitor as set (synchronously inside onSubscribe, or racing it from another thread) was not counted out of the connection. The ref-count stayed inflated and the shared upstream was never disconnected.

cancel() now always records the cancellation with a CAS retry loop and decrements the count. subscribe() skips connecting only if that cancel already disposed the connection, so other subscribers still waiting to reach n get connected.

Fixes #4289

A subscriber cancelling before setRefCountMonitor/setRefConnection had
marked the monitor as set (synchronously inside onSubscribe, or racing
it from another thread) was not counted out of the connection. The
ref-count stayed inflated and the shared upstream was never disconnected.

cancel() now always records the cancellation with a CAS retry loop and
decrements the count. subscribe() skips connecting only if that cancel
already disposed the connection, so other subscribers still waiting to
reach n get connected.

Fixes #4289

Signed-off-by: Dariusz Jędrzejczyk <dariusz.jedrzejczyk@broadcom.com>
@chemicL chemicL added the type/bug A general bug label Oct 19, 2026
@chemicL
chemicL requested a review from a team as a code owner October 19, 2026 13:01
Signed-off-by: Dariusz Jędrzejczyk <dariusz.jedrzejczyk@broadcom.com>

This branch has not been deployed

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

Labels

type/bug A general bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant