diff --git a/BUILD b/BUILD index 1ac645d8aff01b271dce23192321d657c22907e5..459aebd820d021833ce22c582b7894f8b00000b7 100644 --- a/BUILD +++ b/BUILD @@ -785,7 +785,6 @@ cc_library( "src/cpp/common/call.cc", "src/cpp/common/channel_arguments.cc", "src/cpp/common/completion_queue.cc", - "src/cpp/common/grpc_library_initializer.cc", "src/cpp/common/rpc_method.cc", "src/cpp/proto/proto_utils.cc", "src/cpp/server/async_generic_service.cc", @@ -911,7 +910,6 @@ cc_library( "src/cpp/common/call.cc", "src/cpp/common/channel_arguments.cc", "src/cpp/common/completion_queue.cc", - "src/cpp/common/grpc_library_initializer.cc", "src/cpp/common/rpc_method.cc", "src/cpp/proto/proto_utils.cc", "src/cpp/server/async_generic_service.cc", diff --git a/Makefile b/Makefile index a0ae4051e7e7cdedc1be0a05c4b61a480a1aedc5..7e9a4f2ed4faa68b4b73439cd9c29a9027becac3 100644 --- a/Makefile +++ b/Makefile @@ -3015,7 +3015,6 @@ LIBGRPC++_SRC = \ src/cpp/common/call.cc \ src/cpp/common/channel_arguments.cc \ src/cpp/common/completion_queue.cc \ - src/cpp/common/grpc_library_initializer.cc \ src/cpp/common/rpc_method.cc \ src/cpp/proto/proto_utils.cc \ src/cpp/server/async_generic_service.cc \ @@ -3317,7 +3316,6 @@ LIBGRPC++_UNSECURE_SRC = \ src/cpp/common/call.cc \ src/cpp/common/channel_arguments.cc \ src/cpp/common/completion_queue.cc \ - src/cpp/common/grpc_library_initializer.cc \ src/cpp/common/rpc_method.cc \ src/cpp/proto/proto_utils.cc \ src/cpp/server/async_generic_service.cc \ diff --git a/build.yaml b/build.yaml index 1524cc30b7965a128c5f86bda03ef025d3d270bd..aeebb119356a01b8e581ba46088062d59e9470d5 100644 --- a/build.yaml +++ b/build.yaml @@ -84,7 +84,6 @@ filegroups: - src/cpp/common/call.cc - src/cpp/common/channel_arguments.cc - src/cpp/common/completion_queue.cc - - src/cpp/common/grpc_library_initializer.cc - src/cpp/common/rpc_method.cc - src/cpp/proto/proto_utils.cc - src/cpp/server/async_generic_service.cc diff --git a/include/grpc++/impl/grpc_library.h b/include/grpc++/impl/grpc_library.h index f7ff28ec15d870bf275f28b7d009874d0cfd3909..e8a075f5ebb1ced56223723edfcd59a11030811d 100644 --- a/include/grpc++/impl/grpc_library.h +++ b/include/grpc++/impl/grpc_library.h @@ -34,6 +34,8 @@ #ifndef GRPCXX_IMPL_GRPC_LIBRARY_H #define GRPCXX_IMPL_GRPC_LIBRARY_H +#include <iostream> + #include <grpc++/impl/codegen/config.h> #include <grpc++/impl/codegen/grpc_library.h> #include <grpc/grpc.h> @@ -56,11 +58,9 @@ class GrpcLibraryInitializer GRPC_FINAL { /// A no-op method to force the linker to reference this class, which will /// take care of initializing and shutting down the gRPC runtime. - inline void summon() {} + int summon() { return 0; } }; -extern GrpcLibraryInitializer g_gli_initializer; - } // namespace internal } // namespace grpc diff --git a/src/cpp/client/channel.cc b/src/cpp/client/channel.cc index 9b87102f17ccdff9683f72d09cd886e54dec923b..ae20392d1160c7f72b14975753b13f93ab6267e9 100644 --- a/src/cpp/client/channel.cc +++ b/src/cpp/client/channel.cc @@ -53,9 +53,10 @@ namespace grpc { +static internal::GrpcLibraryInitializer g_gli_initializer; Channel::Channel(const grpc::string& host, grpc_channel* channel) : host_(host), c_channel_(channel) { - internal::g_gli_initializer.summon(); + g_gli_initializer.summon(); } Channel::~Channel() { grpc_channel_destroy(c_channel_); } diff --git a/src/cpp/client/credentials.cc b/src/cpp/client/credentials.cc index 51b520bf8393441d63f47e911bbc0e867fdd8ae2..6fb620b0ea8b7c00a815b24b12bafcf5944231cc 100644 --- a/src/cpp/client/credentials.cc +++ b/src/cpp/client/credentials.cc @@ -36,13 +36,12 @@ namespace grpc { -ChannelCredentials::ChannelCredentials() { - internal::g_gli_initializer.summon(); -} +static internal::GrpcLibraryInitializer g_gli_initializer; +ChannelCredentials::ChannelCredentials() { g_gli_initializer.summon(); } ChannelCredentials::~ChannelCredentials() {} -CallCredentials::CallCredentials() { internal::g_gli_initializer.summon(); } +CallCredentials::CallCredentials() { g_gli_initializer.summon(); } CallCredentials::~CallCredentials() {} diff --git a/src/cpp/client/secure_credentials.cc b/src/cpp/client/secure_credentials.cc index bfbcc5f9157d6655c28eaf9320b34aa46d599542..074dae7ca7900cdd652d72a522b854136d66165f 100644 --- a/src/cpp/client/secure_credentials.cc +++ b/src/cpp/client/secure_credentials.cc @@ -41,10 +41,11 @@ namespace grpc { +static internal::GrpcLibraryInitializer g_gli_initializer; SecureChannelCredentials::SecureChannelCredentials( grpc_channel_credentials* c_creds) : c_creds_(c_creds) { - internal::g_gli_initializer.summon(); + g_gli_initializer.summon(); } std::shared_ptr<grpc::Channel> SecureChannelCredentials::CreateChannel( diff --git a/src/cpp/common/alarm.cc b/src/cpp/common/alarm.cc index 604e2c2967d579b1b3531e233fd54f3a90e1a11f..807a67df246b4d44e2dcf101f6b30eeb9273d72e 100644 --- a/src/cpp/common/alarm.cc +++ b/src/cpp/common/alarm.cc @@ -37,9 +37,10 @@ namespace grpc { +static internal::GrpcLibraryInitializer g_gli_initializer; Alarm::Alarm(CompletionQueue* cq, gpr_timespec deadline, void* tag) : alarm_(grpc_alarm_create(cq->cq(), deadline, tag)) { - internal::g_gli_initializer.summon(); + g_gli_initializer.summon(); } Alarm::~Alarm() { grpc_alarm_destroy(alarm_); } diff --git a/src/cpp/common/completion_queue.cc b/src/cpp/common/completion_queue.cc index 0f7b6f63a396895ab2584588381f6ffd82e31506..4f76dfff1d7a73d4eb823f16a4638c2d8f90c12a 100644 --- a/src/cpp/common/completion_queue.cc +++ b/src/cpp/common/completion_queue.cc @@ -42,8 +42,9 @@ namespace grpc { +static internal::GrpcLibraryInitializer g_gli_initializer; CompletionQueue::CompletionQueue() { - internal::g_gli_initializer.summon(); + g_gli_initializer.summon(); cq_ = grpc_completion_queue_create(nullptr); } diff --git a/src/cpp/common/grpc_library_initializer.cc b/src/cpp/common/grpc_library_initializer.cc deleted file mode 100644 index 171efc9238164043e2175451742b4085d46cee94..0000000000000000000000000000000000000000 --- a/src/cpp/common/grpc_library_initializer.cc +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright 2016, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#include <grpc++/impl/grpc_library.h> - -namespace grpc { -namespace internal { - -GrpcLibraryInitializer g_gli_initializer; - -} // namespace internal -} // namespace grpc diff --git a/src/cpp/server/server.cc b/src/cpp/server/server.cc index 1fe0a1eefda1a6eafe95c344879c3fd0c9c9695f..0d31140924bfcc8286a0b5c9467f06cc89af7801 100644 --- a/src/cpp/server/server.cc +++ b/src/cpp/server/server.cc @@ -278,6 +278,7 @@ static grpc_server* CreateServer(const ChannelArguments& args) { return grpc_server_create(&channel_args, nullptr); } +static internal::GrpcLibraryInitializer g_gli_initializer; Server::Server(ThreadPoolInterface* thread_pool, bool thread_pool_owned, int max_message_size, const ChannelArguments& args) : max_message_size_(max_message_size), @@ -289,7 +290,7 @@ Server::Server(ThreadPoolInterface* thread_pool, bool thread_pool_owned, server_(CreateServer(args)), thread_pool_(thread_pool), thread_pool_owned_(thread_pool_owned) { - internal::g_gli_initializer.summon(); + g_gli_initializer.summon(); gpr_once_init(&g_once_init_callbacks, InitGlobalCallbacks); global_callbacks_ = g_callbacks; grpc_server_register_completion_queue(server_, cq_.cq(), nullptr); diff --git a/tools/doxygen/Doxyfile.c++.internal b/tools/doxygen/Doxyfile.c++.internal index 5b1820942067ff3625fa33c3c7a5393fdf674604..558ec9d3947c78bd31ee9b60fe5827867a490b7e 100644 --- a/tools/doxygen/Doxyfile.c++.internal +++ b/tools/doxygen/Doxyfile.c++.internal @@ -857,7 +857,6 @@ src/cpp/client/insecure_credentials.cc \ src/cpp/common/call.cc \ src/cpp/common/channel_arguments.cc \ src/cpp/common/completion_queue.cc \ -src/cpp/common/grpc_library_initializer.cc \ src/cpp/common/rpc_method.cc \ src/cpp/proto/proto_utils.cc \ src/cpp/server/async_generic_service.cc \ diff --git a/tools/run_tests/sources_and_headers.json b/tools/run_tests/sources_and_headers.json index 3405b73ed2a658e60ab2e48820c67b102a159b81..9113f1ca057e39c7153feb431f0aefaa200f73e2 100644 --- a/tools/run_tests/sources_and_headers.json +++ b/tools/run_tests/sources_and_headers.json @@ -4065,7 +4065,6 @@ "src/cpp/common/channel_arguments.cc", "src/cpp/common/completion_queue.cc", "src/cpp/common/create_auth_context.h", - "src/cpp/common/grpc_library_initializer.cc", "src/cpp/common/rpc_method.cc", "src/cpp/common/secure_auth_context.cc", "src/cpp/common/secure_auth_context.h", @@ -4315,7 +4314,6 @@ "src/cpp/common/channel_arguments.cc", "src/cpp/common/completion_queue.cc", "src/cpp/common/create_auth_context.h", - "src/cpp/common/grpc_library_initializer.cc", "src/cpp/common/insecure_create_auth_context.cc", "src/cpp/common/rpc_method.cc", "src/cpp/proto/proto_utils.cc", diff --git a/vsprojects/vcxproj/grpc++/grpc++.vcxproj b/vsprojects/vcxproj/grpc++/grpc++.vcxproj index a146515b75ea29afd47d234207a8210400dabe60..2eea7264471b0530420272bd509ca6599d3590b6 100644 --- a/vsprojects/vcxproj/grpc++/grpc++.vcxproj +++ b/vsprojects/vcxproj/grpc++/grpc++.vcxproj @@ -375,8 +375,6 @@ </ClCompile> <ClCompile Include="$(SolutionDir)\..\src\cpp\common\completion_queue.cc"> </ClCompile> - <ClCompile Include="$(SolutionDir)\..\src\cpp\common\grpc_library_initializer.cc"> - </ClCompile> <ClCompile Include="$(SolutionDir)\..\src\cpp\common\rpc_method.cc"> </ClCompile> <ClCompile Include="$(SolutionDir)\..\src\cpp\proto\proto_utils.cc"> diff --git a/vsprojects/vcxproj/grpc++/grpc++.vcxproj.filters b/vsprojects/vcxproj/grpc++/grpc++.vcxproj.filters index 3d13dec57f0da82bac397dc149dbaffd2f49b443..d5654d0a52fde2db980388ca2e9d77809fb24b1a 100644 --- a/vsprojects/vcxproj/grpc++/grpc++.vcxproj.filters +++ b/vsprojects/vcxproj/grpc++/grpc++.vcxproj.filters @@ -49,9 +49,6 @@ <ClCompile Include="$(SolutionDir)\..\src\cpp\common\completion_queue.cc"> <Filter>src\cpp\common</Filter> </ClCompile> - <ClCompile Include="$(SolutionDir)\..\src\cpp\common\grpc_library_initializer.cc"> - <Filter>src\cpp\common</Filter> - </ClCompile> <ClCompile Include="$(SolutionDir)\..\src\cpp\common\rpc_method.cc"> <Filter>src\cpp\common</Filter> </ClCompile> diff --git a/vsprojects/vcxproj/grpc++_unsecure/grpc++_unsecure.vcxproj b/vsprojects/vcxproj/grpc++_unsecure/grpc++_unsecure.vcxproj index b4a099395a7b7e9f93465bbef5ce132be243967d..013d197dc037c6c8b39ee060e82761a2ffba9371 100644 --- a/vsprojects/vcxproj/grpc++_unsecure/grpc++_unsecure.vcxproj +++ b/vsprojects/vcxproj/grpc++_unsecure/grpc++_unsecure.vcxproj @@ -362,8 +362,6 @@ </ClCompile> <ClCompile Include="$(SolutionDir)\..\src\cpp\common\completion_queue.cc"> </ClCompile> - <ClCompile Include="$(SolutionDir)\..\src\cpp\common\grpc_library_initializer.cc"> - </ClCompile> <ClCompile Include="$(SolutionDir)\..\src\cpp\common\rpc_method.cc"> </ClCompile> <ClCompile Include="$(SolutionDir)\..\src\cpp\proto\proto_utils.cc"> diff --git a/vsprojects/vcxproj/grpc++_unsecure/grpc++_unsecure.vcxproj.filters b/vsprojects/vcxproj/grpc++_unsecure/grpc++_unsecure.vcxproj.filters index 6c54bdc8310972a8b3a1e57a76222a800d5ce62d..039348c7c233ead407f531e86550701974615664 100644 --- a/vsprojects/vcxproj/grpc++_unsecure/grpc++_unsecure.vcxproj.filters +++ b/vsprojects/vcxproj/grpc++_unsecure/grpc++_unsecure.vcxproj.filters @@ -34,9 +34,6 @@ <ClCompile Include="$(SolutionDir)\..\src\cpp\common\completion_queue.cc"> <Filter>src\cpp\common</Filter> </ClCompile> - <ClCompile Include="$(SolutionDir)\..\src\cpp\common\grpc_library_initializer.cc"> - <Filter>src\cpp\common</Filter> - </ClCompile> <ClCompile Include="$(SolutionDir)\..\src\cpp\common\rpc_method.cc"> <Filter>src\cpp\common</Filter> </ClCompile>