Skip to content

binder: Avoid force-terminating BinderTransport on stale unregisterCall task - #13138

Merged
jdcormie merged 1 commit into
grpc:masterfrom
jdcormie:stale-unregister-call
Oct 22, 2026
Merged

jdcormie merged 1 commit into
grpc:masterfrom
jdcormie:stale-unregister-call

Conversation

@jdcormie

Copy link
Copy Markdown
Member

When an ongoing call finishes and unregisterCall() observes ongoingCalls.isEmpty(), it schedules a task on scheduledExecutorService to finish transport shutdown if the transport is in TransportState.SHUTDOWN. However, unregisterCall() runs without holding synchronized (this) and may have scheduled this task while the transport is still in TransportState.READY. If a new stream is created before the transport enters TransportState.SHUTDOWN, the previously scheduled task can execute after shutdown() and call shutdownInternal(shutdownStatus, true), force-terminating the newly started call with UNAVAILABLE: Channel shutdown invoked.

Pass forceTerminate = false to shutdownInternal() so it re-checks ongoingCalls.isEmpty() while holding synchronized (this).

…ll task

When an ongoing call finishes and `unregisterCall()` observes
`ongoingCalls.isEmpty()`, it schedules a task on
`scheduledExecutorService` to finish transport shutdown if the transport
is in `TransportState.SHUTDOWN`. However, `unregisterCall()` runs
without holding `synchronized (this)` and may have scheduled this task
while the transport is still in `TransportState.READY`. If a new stream
is created before the transport enters `TransportState.SHUTDOWN`, the
previously scheduled task can execute after `shutdown()` and call
`shutdownInternal(shutdownStatus, true)`, force-terminating the newly
started call with `UNAVAILABLE: Channel shutdown invoked`.

Pass `forceTerminate = false` to `shutdownInternal()` so it re-checks
`ongoingCalls.isEmpty()` while holding `synchronized (this)`.
@jdcormie
jdcormie requested a review from ejona86 October 22, 2026 05:22
@jdcormie
jdcormie merged commit ed3bf6b into grpc:master Oct 22, 2026
17 of 18 checks passed
@jdcormie
jdcormie deleted the stale-unregister-call branch October 22, 2026 17:21
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.

2 participants