grpc-java icon indicating copy to clipboard operation
grpc-java copied to clipboard

binder: synchronize in-use stream updates

Open becomeStar opened this issue 1 month ago • 2 comments

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

becomeStar avatar Oct 31 '25 04:10 becomeStar

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?

becomeStar avatar Oct 31 '25 15:10 becomeStar

@jdcormie Ping.

kannanjgithub avatar Dec 09 '25 09:12 kannanjgithub