Don't dynamically allocate default server context (#25576)

pull/25430/head
Vijay Pai 4 years ago committed by GitHub
parent 2fd9f5ead9
commit 2a656ce68b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 9
      src/cpp/server/server_cc.cc

@ -549,8 +549,8 @@ class Server::CallbackRequest final
if (has_request_payload_ && request_payload_) {
grpc_byte_buffer_destroy(request_payload_);
}
if (server_->context_allocator() == nullptr || ctx_alloc_by_default_) {
delete ctx_;
if (ctx_alloc_by_default_ || server_->context_allocator() == nullptr) {
default_ctx_.Destroy();
}
server_->UnrefWithPossibleNotify();
}
@ -669,8 +669,8 @@ class Server::CallbackRequest final
data->call = &call_;
data->initial_metadata = &request_metadata_;
if (ctx_ == nullptr) {
// TODO(ddyihai): allocate the context with grpc_call_arena_alloc.
ctx_ = new ServerContextType();
default_ctx_.Init();
ctx_ = &*default_ctx_;
ctx_alloc_by_default_ = true;
}
ctx_->set_context_allocator(server->context_allocator());
@ -692,6 +692,7 @@ class Server::CallbackRequest final
bool ctx_alloc_by_default_ = false;
CallbackCallTag tag_;
ServerContextType* ctx_ = nullptr;
grpc_core::ManualConstructor<ServerContextType> default_ctx_;
grpc::internal::InterceptorBatchMethodsImpl interceptor_methods_;
};

Loading…
Cancel
Save