Merge pull request #10410 from yang-g/add_port

Add ports to global server callback.
pull/10420/head
Yang Gao 8 years ago committed by GitHub
commit dcc9d5c780
  1. 2
      include/grpc++/server.h
  2. 4
      src/cpp/server/server_cc.cc

@ -88,6 +88,8 @@ class Server final : public ServerInterface, private GrpcLibraryCodegen {
virtual void PostSynchronousRequest(ServerContext* context) = 0;
/// Called before server is started.
virtual void PreServerStart(Server* server) {}
/// Called after a server port is added.
virtual void AddPort(Server* server, int port) {}
};
/// 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

@ -489,7 +489,9 @@ void Server::RegisterAsyncGenericService(AsyncGenericService* service) {
int Server::AddListeningPort(const grpc::string& addr,
ServerCredentials* creds) {
GPR_ASSERT(!started_);
return creds->AddPortToServer(addr, server_);
int port = creds->AddPortToServer(addr, server_);
global_callbacks_->AddPort(this, port);
return port;
}
bool Server::Start(ServerCompletionQueue** cqs, size_t num_cqs) {

Loading…
Cancel
Save