How does ServerAsyncResponseWriter::Finish() in a async c++ server detect the timeout event ?

20 views
Skip to first unread message

Arthur Wang

unread,
Jul 9, 2019, 9:42:22 AM7/9/19
to grpc.io
Hi all:
 
  According to the the official document of the grpc_impl::CompletionQueue::Next() method: 

  Server-side Finish, : ok means that the data/metadata/status/etc is going to go to the wire. If it is false, it not going to the wire because the call is already dead (i.e., canceled, deadline expired, other side dropped the channel, etc).

I've also prove it by an experiment:  setting the timeout deadline to A on the client side, and sleeping on the server side for B which ensures that the timeout event will indeed happened.  And the server side Next() is exactly acting like what the document said : it return a false value for the ok output parameter.

But what I can't understand is : how does the server detect the timeout event ? Just by the deadline value set on the client side ?  If it's ture, the clocks may diff slightly between the server and the client, resulting in an inaccurate judgement.

Can someone help explaining this ?  Thanks.

- Regards
- Arthur

Yang Gao

unread,
Jul 9, 2019, 12:33:32 PM7/9/19
to Arthur Wang, grpc.io
(adding back grpc-io)

The client sends the relative timeout value (https://github.com/grpc/grpc/blob/master/doc/PROTOCOL-HTTP2.md) over the wire to the server. The server receives the value and thus knows the timeout. The server can then set a timer to fire after the timeout to notify the rpc is cancelled.

The timeout value is generated on the client side before sending out the rpc by subtracting time_now() from the user-set deadline.

On Tue, Jul 9, 2019 at 9:22 AM Arthur Wang <pplo...@gmail.com> wrote:
grpc sends the timeout over the wire  

I can't understand what does this mean.
 
If you are meaning the relative timeout value,  but how could the server knows about this?  It's set on the client side in an absolute deadline form, no way for the server to knows about it.

On Tue, Jul 9, 2019 at 11:02 PM Yang Gao <ya...@google.com> wrote:
grpc sends the timeout over the wire rather than the absolute deadline. Thus the clock diff should not matter.

--
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 view this discussion on the web visit https://groups.google.com/d/msgid/grpc-io/CAKymdqM6RSgNq22VL8keMsRKYpi%3DAMQ1CxdCLagtSqHwGWUYjw%40mail.gmail.com.

Arthur Wang

unread,
Jul 9, 2019, 1:28:47 PM7/9/19
to Yang Gao, grpc.io
Alright, that make sense. 

Thanks a lot. Yang.
Reply all
Reply to author
Forward
0 new messages