C++ async call data deletion

52 views
Skip to first unread message

nic...@verbsurgical.com

unread,
Mar 18, 2019, 7:00:06 PM3/18/19
to grpc.io
Hi,

I have a question about the behavior of gRPC C++ async; If the call data is deleted in the middle of a call, for example, in a server streaming call, where call data is:

struct CallData {
  grpc::ServerContext ctx;
  RpcRequest request;
  grpc::ServerAsyncWriter<RpcResponse> response_writer;
}

Is the behavor defined if this call data is deleted before calling response_writer.Finish(...) and receiving the returned tag.  Ie. the from a previous call to response_writer.Write(...) was returned, but before invoking Finish(), the CallData is deleted.  My assumption is that the call would be cancelled and the client would receive an error.  But should we expect to see gRPC assertion failures on the server side during cleanup, or should the server still be able to process additional requests, and shutdown cleanly?

Thanks!
Nick

Vijay Pai

unread,
Mar 19, 2019, 1:06:03 PM3/19/19
to grpc.io
The ServerContext needs to stay alive for the duration of the RPC.

Nick Cox

unread,
Mar 19, 2019, 1:19:47 PM3/19/19
to Vijay Pai, grpc.io
Is the behavior undefined if it doesn't?

--
You received this message because you are subscribed to the Google Groups "grpc.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email to grpc-io+u...@googlegroups.com.
To post to this group, send email to grp...@googlegroups.com.
Visit this group at https://groups.google.com/group/grpc-io.
To view this discussion on the web visit https://groups.google.com/d/msgid/grpc-io/28f0e823-e4ff-48a7-8f7c-569f458142bc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Vijay Pai

unread,
Mar 19, 2019, 2:04:46 PM3/19/19
to grpc.io
Yes, it's an API expectation that ServerContext is alive for the duration of the RPC and there is no guaranteed behavior otherwise.

Nick Cox

unread,
Mar 19, 2019, 2:10:16 PM3/19/19
to Vijay Pai, grpc.io
Thanks, that clarification helps.  For call duration, is the end of the call defined as when Finish() is invoked, or when the tag is returned from the completion queue after the call to Finish()?  I suspect it's the latter, but I just want to confirm.

Thanks!
Nick

Vijay Pai

unread,
Mar 19, 2019, 3:11:18 PM3/19/19
to grpc.io
Yup, it is over when the tag comes back from finish

Nick Cox

unread,
Mar 19, 2019, 3:29:20 PM3/19/19
to Vijay Pai, grpc.io
Thanks!

On Tue, Mar 19, 2019, 12:11 PM 'Vijay Pai' via grpc.io <grp...@googlegroups.com> wrote:
Yup, it is over when the tag comes back from finish

--
You received this message because you are subscribed to the Google Groups "grpc.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email to grpc-io+u...@googlegroups.com.
To post to this group, send email to grp...@googlegroups.com.
Visit this group at https://groups.google.com/group/grpc-io.
Reply all
Reply to author
Forward
0 new messages