Skip to content
Snippets Groups Projects
Commit ded3f697 authored by Craig Tiller's avatar Craig Tiller
Browse files

Merge pull request #2442 from yang-g/authcontext_lazy_create_at_server

Create server side auth context lazily
parents 5a9674c0 94d6225a
No related branches found
No related tags found
No related merge requests found
......@@ -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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment