Skip to content

Conversation

@becomeStar
Copy link
Contributor

Fixes a race between newStream() and unregisterInbound() that could cause inconsistent transportInUse() notifications. The updates to numInUseStreams are now synchronized via updateInUseStreamsIfNeed(), ensuring listener state remains accurate.
Also replaced AtomicInteger with a primitive int since synchronization makes atomic operations unnecessary.

Fixes #10917

…ronizing in-use updates

Previously, concurrent calls to newStream() and unregisterInbound() could both
 update numInUseStreams and invoke transportInUse() in conflicting order,
 leading to inconsistent listener state. This change synchronizes updates and
 only notifies the listener on transitions between 0 and >0.

 Fixes grpc#10917
@becomeStar
Copy link
Contributor Author

becomeStar commented Oct 31, 2025

I’m considering adding a unit test for updateInUseStreamsIfNeed() (with VisibleForTesting annotation)
to verify its behavior on in-use state transitions.
Would you prefer this test to be included in the same PR or in a separate one?

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.

binder: ManagedClientTransport.Listener invocations are not properly synchronized

1 participant