best way to force shutdown of synchronous C++ server

1,614 views
Skip to first unread message

howarth

unread,
Jan 24, 2017, 6:11:25 PM1/24/17
to grpc.io
I'm using gRPC to run a streaming subscription service. My rpc subscription handler does not return so that the connection between client and server remains open.

Is there a way to force a shutdown given that my existing subscription rpcs won't finish on their own? Both the normal Shutdown and Shutdown with a deadline hang forever in this case.

Craig Tiller

unread,
Jan 24, 2017, 7:39:51 PM1/24/17
to howarth, grpc.io
Shutdown with deadline will trigger IsCancelled() on the server context to become true once the deadline fires, and you could use that bit to make your handlers exit.

On Tue, Jan 24, 2017 at 3:11 PM 'howarth' via grpc.io <grp...@googlegroups.com> wrote:
I'm using gRPC to run a streaming subscription service. My rpc subscription handler does not return so that the connection between client and server remains open.

Is there a way to force a shutdown given that my existing subscription rpcs won't finish on their own? Both the normal Shutdown and Shutdown with a deadline hang forever in this case.

--
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/0a56de4a-807e-4095-996f-6de902bb37dc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

how...@google.com

unread,
Jan 24, 2017, 8:11:26 PM1/24/17
to grpc.io, how...@google.com
Thank you for the tip. There's no mutex+cond var built in for this purpose, right? I need a way to wake up my rpc handler to check IsCancelled(), but I can't signal after calling Shutdown because shutdown is blocking.

Craig Tiller

unread,
Jan 24, 2017, 8:14:34 PM1/24/17
to how...@google.com, grpc.io
There's not.

We've talked about having a std::function argument to Shutdown that would fire when the deadline elapses (I'm against a particular concurrency expression (mutex/condvar for instance) here since every app ends up wanting different things).

There's no plans to implement it just yet, but it's likely doable.

Reply all
Reply to author
Forward
0 new messages