Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Binder: address race condition where a new transport may attempt to s… #11253

Closed
wants to merge 1 commit into from

Conversation

mateusazis
Copy link
Contributor

…tart despite the server having shutdown already.

Part of #10897.

…tart despite the server having shutdown already.

Part of grpc#10897.
@mateusazis
Copy link
Contributor Author

I didn't find a good way to test this. I looked into BinderTransportTest, but calling transport.shutdownNow() forbids me from starting new transports for that service. HostServices attempts to spin up a new server intead. Let me know if you have any ideas.

@@ -135,6 +135,13 @@ public String toString() {

@Override
public synchronized boolean handleTransaction(int code, Parcel parcel) {
// It's possible that a transaction had started mid-server shutdown. In that case, should not
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about:

// After reporting ServerListener#serverShutdown() above, the InternalServer API contract forbids us from creating any new ServerTransports. But any incoming SETUP_TRANSPORT transactions that were already in-flight before shutdown are still going to arrive here. We must not accept them and the easiest thing is just to ignore.

@jdcormie
Copy link
Member

I didn't find a good way to test this. I looked into BinderTransportTest, but calling transport.shutdownNow() forbids me from starting new transports for that service. HostServices attempts to spin up a new server intead. Let me know if you have any ideas.

Yeah this is basically AbstractTransportTest#serverNotListening(), which BinderTransportTest currently @Ignores (#8931). Plus the extra challenge of getting your SETUP_TRANSPORT through after shutdown() but before hostServiceBinder.detach();.

It would be difficult but you could:

  1. substitute in a different implementation of LeakSafeOneWayBinder that delayed detach() actuation.
  2. Instead of silently dropping SETUP_TRANSPORT after shutdown, have BinderServer reply (over callbackBinder) with SHUTDOWN_TRANSPORT. Kind of like a GOAWAY response.

We could then just re-enable AbstractTransportTest#serverNotListening().

@mateusazis
Copy link
Contributor Author

No longer needed since #11260

@mateusazis mateusazis closed this Jun 6, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 5, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants