Merge pull request #2442 from yang-g/authcontext_lazy_create_at_server

Create server side auth context lazily
pull/2467/head
Craig Tiller 10 years ago
commit ded3f69716
  1. 6
      include/grpc++/server_context.h
  2. 7
      src/cpp/server/server_context.cc

@ -99,9 +99,7 @@ class ServerContext {
return client_metadata_;
}
std::shared_ptr<const AuthContext> auth_context() const {
return auth_context_;
}
std::shared_ptr<const AuthContext> auth_context() const;
private:
friend class ::grpc::Server;
@ -147,7 +145,7 @@ class ServerContext {
grpc_call* call_;
CompletionQueue* cq_;
bool sent_initial_metadata_;
std::shared_ptr<const AuthContext> auth_context_;
mutable std::shared_ptr<const AuthContext> auth_context_;
std::multimap<grpc::string, grpc::string> client_metadata_;
std::multimap<grpc::string, grpc::string> initial_metadata_;
std::multimap<grpc::string, grpc::string> trailing_metadata_;

@ -153,4 +153,11 @@ void ServerContext::set_call(grpc_call* call) {
auth_context_ = CreateAuthContext(call);
}
std::shared_ptr<const AuthContext> ServerContext::auth_context() const {
if (auth_context_.get() == nullptr) {
auth_context_ = CreateAuthContext(call_);
}
return auth_context_;
}
} // namespace grpc

Loading…
Cancel
Save