diff options
Diffstat (limited to 'src/cpp')
-rw-r--r-- | src/cpp/client/client_context.cc | 1 | ||||
-rw-r--r-- | src/cpp/codegen/codegen_init.cc | 6 | ||||
-rw-r--r-- | src/cpp/ext/proto_server_reflection.cc | 4 | ||||
-rw-r--r-- | src/cpp/ext/proto_server_reflection_plugin.cc | 8 | ||||
-rw-r--r-- | src/cpp/server/server.cc | 6 | ||||
-rw-r--r-- | src/cpp/server/server_builder.cc | 17 | ||||
-rw-r--r-- | src/cpp/server/server_posix.cc | 2 |
7 files changed, 23 insertions, 21 deletions
diff --git a/src/cpp/client/client_context.cc b/src/cpp/client/client_context.cc index d3e5ce0c4a..0ba77a5057 100644 --- a/src/cpp/client/client_context.cc +++ b/src/cpp/client/client_context.cc @@ -63,6 +63,7 @@ ClientContext::ClientContext() call_(nullptr), call_canceled_(false), deadline_(gpr_inf_future(GPR_CLOCK_REALTIME)), + census_context_(nullptr), propagate_from_call_(nullptr) { g_client_callbacks->DefaultConstructor(this); } diff --git a/src/cpp/codegen/codegen_init.cc b/src/cpp/codegen/codegen_init.cc index c5d22124b7..103a7c1258 100644 --- a/src/cpp/codegen/codegen_init.cc +++ b/src/cpp/codegen/codegen_init.cc @@ -34,12 +34,12 @@ #include <grpc++/impl/codegen/core_codegen_interface.h> #include <grpc++/impl/codegen/grpc_library.h> -/// Initializes the global gRPC variables for the codegen library. These will +/// Null-initializes the global gRPC variables for the codegen library. These /// stay null in the absence of of grpc++ library. In this case, no gRPC /// features such as the ability to perform calls will be available. Trying to /// perform them would result in a segmentation fault when trying to deference /// the following nulled globals. These should be associated with actual /// as part of the instantiation of a \a grpc::GrpcLibraryInitializer variable. -grpc::CoreCodegenInterface* grpc::g_core_codegen_interface = nullptr; -grpc::GrpcLibraryInterface* grpc::g_glip = nullptr; +grpc::CoreCodegenInterface* grpc::g_core_codegen_interface; +grpc::GrpcLibraryInterface* grpc::g_glip; diff --git a/src/cpp/ext/proto_server_reflection.cc b/src/cpp/ext/proto_server_reflection.cc index 348a035f0f..3973bfb58e 100644 --- a/src/cpp/ext/proto_server_reflection.cc +++ b/src/cpp/ext/proto_server_reflection.cc @@ -197,8 +197,8 @@ Status ProtoServerReflection::GetAllExtensionNumbers( std::vector<const protobuf::FieldDescriptor*> extensions; descriptor_pool_->FindAllExtensions(desc, &extensions); - for (auto extension : extensions) { - response->add_extension_number(extension->number()); + for (auto it = extensions.begin(); it != extensions.end(); it++) { + response->add_extension_number((*it)->number()); } response->set_base_type_name(type); return Status::OK; diff --git a/src/cpp/ext/proto_server_reflection_plugin.cc b/src/cpp/ext/proto_server_reflection_plugin.cc index f31d102a9e..5b806ce1ae 100644 --- a/src/cpp/ext/proto_server_reflection_plugin.cc +++ b/src/cpp/ext/proto_server_reflection_plugin.cc @@ -60,21 +60,21 @@ void ProtoServerReflectionPlugin::ChangeArguments(const grpc::string& name, void* value) {} bool ProtoServerReflectionPlugin::has_sync_methods() const { - if (reflection_service_ != nullptr) { + if (reflection_service_) { return reflection_service_->has_synchronous_methods(); } return false; } bool ProtoServerReflectionPlugin::has_async_methods() const { - if (reflection_service_ != nullptr) { + if (reflection_service_) { return reflection_service_->has_async_methods(); } return false; } -static std::unique_ptr<::grpc::ServerBuilderPlugin> CreateProtoReflection() { - return std::unique_ptr<::grpc::ServerBuilderPlugin>( +static std::unique_ptr< ::grpc::ServerBuilderPlugin> CreateProtoReflection() { + return std::unique_ptr< ::grpc::ServerBuilderPlugin>( new ProtoServerReflectionPlugin()); } diff --git a/src/cpp/server/server.cc b/src/cpp/server/server.cc index 50fc4733a1..fb4c68ebe4 100644 --- a/src/cpp/server/server.cc +++ b/src/cpp/server/server.cc @@ -67,7 +67,7 @@ static std::shared_ptr<Server::GlobalCallbacks> g_callbacks = nullptr; static gpr_once g_once_init_callbacks = GPR_ONCE_INIT; static void InitGlobalCallbacks() { - if (g_callbacks == nullptr) { + if (!g_callbacks) { g_callbacks.reset(new DefaultGlobalCallbacks()); } } @@ -324,8 +324,8 @@ Server::~Server() { } void Server::SetGlobalCallbacks(GlobalCallbacks* callbacks) { - GPR_ASSERT(g_callbacks == nullptr); - GPR_ASSERT(callbacks != nullptr); + GPR_ASSERT(!g_callbacks); + GPR_ASSERT(callbacks); g_callbacks.reset(callbacks); } diff --git a/src/cpp/server/server_builder.cc b/src/cpp/server/server_builder.cc index 279981744a..45bb858e2e 100644 --- a/src/cpp/server/server_builder.cc +++ b/src/cpp/server/server_builder.cc @@ -55,9 +55,10 @@ static void do_plugin_list_init(void) { ServerBuilder::ServerBuilder() : max_message_size_(-1), generic_service_(nullptr) { gpr_once_init(&once_init_plugin_list, do_plugin_list_init); - for (auto factory : (*g_plugin_factory_list)) { - std::unique_ptr<ServerBuilderPlugin> plugin = factory(); - plugins_[plugin->name()] = std::move(plugin); + for (auto it = g_plugin_factory_list->begin(); + it != g_plugin_factory_list->end(); it++) { + auto& factory = *it; + plugins_.emplace_back(factory()); } // all compression algorithms enabled by default. enabled_compression_algorithms_bitset_ = @@ -141,7 +142,7 @@ std::unique_ptr<Server> ServerBuilder::BuildAndStart() { bool has_sync_methods = false; for (auto it = services_.begin(); it != services_.end(); ++it) { if ((*it)->service->has_synchronous_methods()) { - if (thread_pool == nullptr) { + if (!thread_pool) { thread_pool.reset(CreateDefaultThreadPool()); has_sync_methods = true; break; @@ -153,9 +154,9 @@ std::unique_ptr<Server> ServerBuilder::BuildAndStart() { (*option)->UpdateArguments(&args); (*option)->UpdatePlugins(&plugins_); } - if (thread_pool == nullptr) { + if (!thread_pool) { for (auto plugin = plugins_.begin(); plugin != plugins_.end(); plugin++) { - if ((*plugin).second->has_sync_methods()) { + if ((*plugin)->has_sync_methods()) { thread_pool.reset(CreateDefaultThreadPool()); has_sync_methods = true; break; @@ -212,7 +213,7 @@ std::unique_ptr<Server> ServerBuilder::BuildAndStart() { } } for (auto plugin = plugins_.begin(); plugin != plugins_.end(); plugin++) { - (*plugin).second->InitServer(initializer); + (*plugin)->InitServer(initializer); } if (generic_service_) { server->RegisterAsyncGenericService(generic_service_); @@ -238,7 +239,7 @@ std::unique_ptr<Server> ServerBuilder::BuildAndStart() { return nullptr; } for (auto plugin = plugins_.begin(); plugin != plugins_.end(); plugin++) { - (*plugin).second->Finish(initializer); + (*plugin)->Finish(initializer); } return server; } diff --git a/src/cpp/server/server_posix.cc b/src/cpp/server/server_posix.cc index 8cb9753a12..c3aa2adc60 100644 --- a/src/cpp/server/server_posix.cc +++ b/src/cpp/server/server_posix.cc @@ -42,8 +42,8 @@ namespace grpc { void AddInsecureChannelFromFd(Server* server, int fd) { grpc_server_add_insecure_channel_from_fd( server->c_server(), server->completion_queue()->cq(), fd); +} #endif // GPR_SUPPORT_CHANNELS_FROM_FD -} } // namespace grpc |