grpc-java
grpc-java copied to clipboard
binder: synchronize in-use stream updates
Fixes a race between newStream() and unregisterInbound() that could cause inconsistent transportInUse() notifications.
- Added listenerNotifyLock to synchronize listener callbacks and ensure mutual exclusion.
- Reconcile listenerInUse state with current numInUseStreams to avoid stale toggles under concurrent updates.
- Ensure transportInUse() is only called when the in-use state actually changes.
- Concurrency-sensitive areas have been considered; additional unit/integration tests may be added upon review.
Fixes #10917
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?
@jdcormie Ping.