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

Make ServerImpl's internalClose thread-safe #3746

Open
ejona86 opened this issue Nov 15, 2017 · 1 comment · May be fixed by #11864
Open

Make ServerImpl's internalClose thread-safe #3746

ejona86 opened this issue Nov 15, 2017 · 1 comment · May be fixed by #11864
Labels
Milestone

Comments

@ejona86
Copy link
Member

ejona86 commented Nov 15, 2017

So we have this in ServerImpl.JumpToApplicationThreadServerStreamListener:

/**
 * Like {@link ServerCall#close(Status, Metadata)}, but thread-safe for internal use.
 */
private void internalClose() {
  // TODO(ejona86): this is not thread-safe :)
  stream.close(Status.UNKNOWN, new Metadata());
}

We should fix that. There's two ways to fix this:

  1. Allow truncated messages in our stream and deliver trailers. This would be nicest and would be helpful in other cases (like if too many requests are sent in a server call), as we can deliver a message to the client
  2. Treat this as a cancel and send RST_STREAM. This would be similar to client-side cancellation, but we'd still need to verify it'd be safe on server-side.

In either case it'd probably be good if we made this trigger onCancel instead of onCompleted. That'd probably happen naturally for (2), but (1) would need special plumbing, but it's probably not too onerous.

@ejona86
Copy link
Member Author

ejona86 commented Mar 2, 2018

As seen in #4168, the RST_STREAM option doesn't work in the case the server hasn't sent anything yet, as users may be expecting UNKNOWN.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant