-
Notifications
You must be signed in to change notification settings - Fork 37
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
Question: Is it okay to call finish with an outstanding read in the server? #111
Comments
Since asio-grpc's documentation is just a copy of the official gRPC documentation, we can look there for answers. Here is bidi-streaming
We can also take a look at I think the gRPC documentation is not very clear, what is meant by other streaming APIs? I assumed they meant every other function, e.g. |
Looks like calling read and finish concurrently does not cause a crash. Note that my tests are compiled in Release, so no assertions. I recommend that you test it yourself in Debug with assertions. Let me know the outcome then I can update asio-grpc documentation. |
I ran the tests in a debug build and they passed just fine. |
Looks like I have misunderstood your question. It is in fact OK to initiate a finish after initiating a read but it is not OK to initiate rpc.read(request, [](bool) {});
// OK, read is initiated and may be outstanding, we can initiate finish:
co_await rpc.finish(...);
// Looks like gRPC even guarantees that `read()` will have completed before we get here Compare that to: std::thread t{[&] {
rpc.read(request, [](bool) {}); // Not OK. In fact this could end up initiating read() after finish() completed which is disallowed anyways
}};
co_await rpc.finish(...); |
okay thanks for clarifying. I will close the question |
Hi,
I want to clarify if its okay to call finish with an outstanding read in the server.
From the best practices section item 24 of grpc-cpp i think it should be okay.
The documentation of asio grpc however states
Is running finish and read on a strand okay?
What i want to achieve is a bidirectional grpc server that finishes a rpc with a status code (not cancellation) even if the client has not sent all requests or hasn't called
writesDone
.thanks and best regards,
Lars
The text was updated successfully, but these errors were encountered: