Fixed wrong usage of global var

pull/4775/head
David Garcia Quintas 9 years ago
parent 6523391782
commit d79ef3af71
  1. 2
      BUILD
  2. 2
      Makefile
  3. 1
      build.yaml
  4. 6
      include/grpc++/impl/grpc_library.h
  5. 3
      src/cpp/client/channel.cc
  6. 7
      src/cpp/client/credentials.cc
  7. 3
      src/cpp/client/secure_credentials.cc
  8. 3
      src/cpp/common/alarm.cc
  9. 3
      src/cpp/common/completion_queue.cc
  10. 41
      src/cpp/common/grpc_library_initializer.cc
  11. 3
      src/cpp/server/server.cc
  12. 1
      tools/doxygen/Doxyfile.c++.internal
  13. 2
      tools/run_tests/sources_and_headers.json
  14. 2
      vsprojects/vcxproj/grpc++/grpc++.vcxproj
  15. 3
      vsprojects/vcxproj/grpc++/grpc++.vcxproj.filters
  16. 2
      vsprojects/vcxproj/grpc++_unsecure/grpc++_unsecure.vcxproj
  17. 3
      vsprojects/vcxproj/grpc++_unsecure/grpc++_unsecure.vcxproj.filters

@ -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",

@ -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 \

@ -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

@ -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

@ -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_); }

@ -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() {}

@ -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(

@ -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_); }

@ -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);
}

@ -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

@ -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);

@ -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 \

@ -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",

@ -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">

@ -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>

@ -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">

@ -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>

Loading…
Cancel
Save