From f2fe4f7dbd00a285f265167bb8fec5c48fd7345b Mon Sep 17 00:00:00 2001
From: yang-g <yangg@google.com>
Date: Tue, 7 Feb 2017 12:47:22 -0800
Subject: [PATCH] Add a PreServerStart in global server callbacks

---
 include/grpc++/server.h     | 2 ++
 src/cpp/server/server_cc.cc | 1 +
 2 files changed, 3 insertions(+)

diff --git a/include/grpc++/server.h b/include/grpc++/server.h
index fba9952e6e..002f252a8f 100644
--- a/include/grpc++/server.h
+++ b/include/grpc++/server.h
@@ -88,6 +88,8 @@ class Server final : public ServerInterface, private GrpcLibraryCodegen {
     virtual void PreSynchronousRequest(ServerContext* context) = 0;
     /// Called after application callback for each synchronous server request
     virtual void PostSynchronousRequest(ServerContext* context) = 0;
+    /// Called before server is started.
+    virtual void PreServerStart(Server* server) {}
   };
   /// Set the global callback object. Can only be called once. Does not take
   /// ownership of callbacks, and expects the pointed to object to be alive
diff --git a/src/cpp/server/server_cc.cc b/src/cpp/server/server_cc.cc
index f6a7f1d755..29898a4209 100644
--- a/src/cpp/server/server_cc.cc
+++ b/src/cpp/server/server_cc.cc
@@ -478,6 +478,7 @@ int Server::AddListeningPort(const grpc::string& addr,
 
 bool Server::Start(ServerCompletionQueue** cqs, size_t num_cqs) {
   GPR_ASSERT(!started_);
+  global_callbacks_->PreServerStart(this);
   started_ = true;
   grpc_server_start(server_);
 
-- 
GitLab