From e50e5cbde2f77166b9f557938252de6792557f84 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Tue, 18 Aug 2015 12:44:57 -0700 Subject: Add a timeout to shutdown to forcefully end calls --- include/grpc++/server.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/grpc++/server.h b/include/grpc++/server.h index 8755b4b445..084c9936d5 100644 --- a/include/grpc++/server.h +++ b/include/grpc++/server.h @@ -63,7 +63,13 @@ class Server GRPC_FINAL : public GrpcLibrary, private CallHook { ~Server(); // Shutdown the server, block until all rpc processing finishes. - void Shutdown(); + // Forcefully terminate pending calls after deadline expires. + template + void Shutdown(const T& deadline) { + ShutdownInternal(TimePoint(deadline).raw_time()); + } + + void Shutdown() { ShutdownInternal(gpr_inf_future(GPR_CLOCK_MONOTONIC)); } // Block waiting for all work to complete (the server must either // be shutting down or some other thread must call Shutdown for this @@ -98,6 +104,8 @@ class Server GRPC_FINAL : public GrpcLibrary, private CallHook { void PerformOpsOnCall(CallOpSetInterface* ops, Call* call) GRPC_OVERRIDE; + void ShutdownInternal(gpr_timespec deadline); + class BaseAsyncRequest : public CompletionQueueTag { public: BaseAsyncRequest(Server* server, ServerContext* context, -- cgit v1.2.3