completionqueue->next return False when client called WritesDone

25 views
Skip to first unread message

Lingzi Peng

unread,
Oct 18, 2018, 6:09:19 AM10/18/18
to grpc.io
Hi,

I am writing a program with sync streaming client (ClientWriter) and async server.

During the debug, i found that when ClientWriter called WritesDone, cq->next call in server side has ok = false returned.

And after writesDone, client side call Finish, this time cq->next call in server side has ok = true.

In that case, is there any way to differentiate if the ok = false is caused by that client side has quit unexpectedly or  a WritesDone was called? Since in both cases ok = false.


Cheers


Vijay Pai

unread,
Oct 21, 2018, 5:57:53 AM10/21/18
to grpc.io
The meaning of ok is documented at https://github.com/grpc/grpc/blob/be1ce0c4ccbf17ebeee9b7b057d40ff4e12f3479/include/grpcpp/impl/codegen/completion_queue.h#L122-L169 . In particular, note that the meaning of ok depends on the type of operation that is being pulled by the Next operation, so it is perfectly normal to get a "true" ok after a "false" ok, depending on the type of operation being delivered.

For your question: with an async server, the way to tell if the client-side is fully failed or just did a WritesDone is to use an AsyncNotifyWhenDone operation on your ServerContext. After that tag comes through, you can check if the RPC was canceled. The WritesDone would just make a Read operation return false but won't finish the RPC the way a failure or cancellation would.
Reply all
Reply to author
Forward
0 new messages