title: How to shutdown gRPC server from Client (using RPC function)
body: <p>I'm using gRPC for inter-process communication between C++ App (gRPC Server) and Java App (gRPC Client). Everything run on one machine. I want to provide client possibility to shut down the server. My idea is to add RPC function to service in proto which would do it.  </p>
  
  <p>The C++ Implementation would be:</p>
  
  <pre><code>class Service : public grpcGeneratedService
  {
  public:
  ......
  private:  
      grpc::Server* m_pServer;
  };
  grpc::Status Service::ShutDown(grpc::ServerContext* pContext, const ShutDownRequest* pRequest, ShutDownResponse* pResponse)
  {
      if (m_pServer)
          m_pServer-&gt;Shutdown();
      return grpc::Status(grpc::StatusCode::OK, "");
  }
  </code></pre>
  
  <p>However the ShutDown blocks until all RPC calls are processed what means dead-lock. Is there any elegant way how to implement it? </p>