aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--BUILD2
-rw-r--r--Makefile2
-rw-r--r--build.json1
-rw-r--r--examples/pubsub/main.cc3
-rw-r--r--examples/pubsub/publisher_test.cc2
-rw-r--r--examples/pubsub/subscriber_test.cc2
-rw-r--r--include/grpc++/completion_queue.h5
-rw-r--r--include/grpc++/credentials.h5
-rw-r--r--include/grpc++/impl/grpc_library.h50
-rw-r--r--include/grpc++/server.h4
-rw-r--r--src/cpp/client/channel.h4
-rw-r--r--test/cpp/client/credentials_test.cc2
-rw-r--r--test/cpp/end2end/async_end2end_test.cc5
-rw-r--r--test/cpp/end2end/end2end_test.cc5
-rw-r--r--test/cpp/end2end/generic_end2end_test.cc5
-rw-r--r--test/cpp/interop/client.cc4
-rw-r--r--test/cpp/interop/server.cc2
-rw-r--r--test/cpp/qps/qps_driver.cc2
-rw-r--r--test/cpp/qps/smoke_test.cc3
-rw-r--r--test/cpp/qps/worker.cc4
-rw-r--r--test/cpp/util/cli_call_test.cc5
-rw-r--r--test/cpp/util/grpc_cli.cc4
-rw-r--r--vsprojects/grpc++/grpc++.vcxproj1
-rw-r--r--vsprojects/grpc++/grpc++.vcxproj.filters3
24 files changed, 76 insertions, 49 deletions
diff --git a/BUILD b/BUILD
index 2a93161db2..79070f1c1e 100644
--- a/BUILD
+++ b/BUILD
@@ -621,6 +621,7 @@ cc_library(
"include/grpc++/generic_stub.h",
"include/grpc++/impl/call.h",
"include/grpc++/impl/client_unary_call.h",
+ "include/grpc++/impl/grpc_library.h",
"include/grpc++/impl/internal_stub.h",
"include/grpc++/impl/rpc_method.h",
"include/grpc++/impl/rpc_service_method.h",
@@ -699,6 +700,7 @@ cc_library(
"include/grpc++/generic_stub.h",
"include/grpc++/impl/call.h",
"include/grpc++/impl/client_unary_call.h",
+ "include/grpc++/impl/grpc_library.h",
"include/grpc++/impl/internal_stub.h",
"include/grpc++/impl/rpc_method.h",
"include/grpc++/impl/rpc_service_method.h",
diff --git a/Makefile b/Makefile
index 3e7930b9c3..8cd71600ad 100644
--- a/Makefile
+++ b/Makefile
@@ -3854,6 +3854,7 @@ PUBLIC_HEADERS_CXX += \
include/grpc++/generic_stub.h \
include/grpc++/impl/call.h \
include/grpc++/impl/client_unary_call.h \
+ include/grpc++/impl/grpc_library.h \
include/grpc++/impl/internal_stub.h \
include/grpc++/impl/rpc_method.h \
include/grpc++/impl/rpc_service_method.h \
@@ -4117,6 +4118,7 @@ PUBLIC_HEADERS_CXX += \
include/grpc++/generic_stub.h \
include/grpc++/impl/call.h \
include/grpc++/impl/client_unary_call.h \
+ include/grpc++/impl/grpc_library.h \
include/grpc++/impl/internal_stub.h \
include/grpc++/impl/rpc_method.h \
include/grpc++/impl/rpc_service_method.h \
diff --git a/build.json b/build.json
index 8838d3a630..ec48314d26 100644
--- a/build.json
+++ b/build.json
@@ -28,6 +28,7 @@
"include/grpc++/generic_stub.h",
"include/grpc++/impl/call.h",
"include/grpc++/impl/client_unary_call.h",
+ "include/grpc++/impl/grpc_library.h",
"include/grpc++/impl/internal_stub.h",
"include/grpc++/impl/rpc_method.h",
"include/grpc++/impl/rpc_service_method.h",
diff --git a/examples/pubsub/main.cc b/examples/pubsub/main.cc
index 8f8eefa9ef..3a403481fc 100644
--- a/examples/pubsub/main.cc
+++ b/examples/pubsub/main.cc
@@ -65,7 +65,6 @@ const char kMessageData[] = "Test Data";
} // namespace
int main(int argc, char** argv) {
- grpc_init();
grpc::testing::InitTest(&argc, &argv, true);
gpr_log(GPR_INFO, "Start PUBSUB client");
@@ -146,7 +145,5 @@ int main(int argc, char** argv) {
subscriber.Shutdown();
publisher.Shutdown();
- channel.reset();
- grpc_shutdown();
return 0;
}
diff --git a/examples/pubsub/publisher_test.cc b/examples/pubsub/publisher_test.cc
index ac4921283f..6b9dcacc49 100644
--- a/examples/pubsub/publisher_test.cc
+++ b/examples/pubsub/publisher_test.cc
@@ -148,10 +148,8 @@ TEST_F(PublisherTest, TestPublisher) {
int main(int argc, char** argv) {
grpc_test_init(argc, argv);
- grpc_init();
::testing::InitGoogleTest(&argc, argv);
gpr_log(GPR_INFO, "Start test ...");
int result = RUN_ALL_TESTS();
- grpc_shutdown();
return result;
}
diff --git a/examples/pubsub/subscriber_test.cc b/examples/pubsub/subscriber_test.cc
index 9ab60ed6a7..b0e7fc034b 100644
--- a/examples/pubsub/subscriber_test.cc
+++ b/examples/pubsub/subscriber_test.cc
@@ -147,10 +147,8 @@ TEST_F(SubscriberTest, TestSubscriber) {
int main(int argc, char** argv) {
grpc_test_init(argc, argv);
- grpc_init();
::testing::InitGoogleTest(&argc, argv);
gpr_log(GPR_INFO, "Start test ...");
int result = RUN_ALL_TESTS();
- grpc_shutdown();
return result;
}
diff --git a/include/grpc++/completion_queue.h b/include/grpc++/completion_queue.h
index e6a8c6fe55..0a2a7687b7 100644
--- a/include/grpc++/completion_queue.h
+++ b/include/grpc++/completion_queue.h
@@ -36,6 +36,7 @@
#include <chrono>
#include <grpc++/impl/client_unary_call.h>
+#include <grpc++/impl/grpc_library.h>
#include <grpc/support/time.h>
struct grpc_completion_queue;
@@ -71,11 +72,11 @@ class CompletionQueueTag {
};
// grpc_completion_queue wrapper class
-class CompletionQueue {
+class CompletionQueue : public GrpcLibrary {
public:
CompletionQueue();
explicit CompletionQueue(grpc_completion_queue* take);
- ~CompletionQueue();
+ ~CompletionQueue() GRPC_OVERRIDE;
// Tri-state return for AsyncNext: SHUTDOWN, GOT_EVENT, TIMEOUT
enum NextStatus { SHUTDOWN, GOT_EVENT, TIMEOUT };
diff --git a/include/grpc++/credentials.h b/include/grpc++/credentials.h
index 2ac3eec95c..cbf9445750 100644
--- a/include/grpc++/credentials.h
+++ b/include/grpc++/credentials.h
@@ -38,15 +38,16 @@
#include <memory>
#include <grpc++/config.h>
+#include <grpc++/impl/grpc_library.h>
namespace grpc {
class ChannelArguments;
class ChannelInterface;
class SecureCredentials;
-class Credentials {
+class Credentials : public GrpcLibrary {
public:
- virtual ~Credentials();
+ ~Credentials() GRPC_OVERRIDE;
protected:
friend std::unique_ptr<Credentials> CompositeCredentials(
diff --git a/include/grpc++/impl/grpc_library.h b/include/grpc++/impl/grpc_library.h
new file mode 100644
index 0000000000..f9fa677901
--- /dev/null
+++ b/include/grpc++/impl/grpc_library.h
@@ -0,0 +1,50 @@
+/*
+ *
+ * Copyright 2015, 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.
+ *
+ */
+
+#ifndef GRPCXX_IMPL_GRPC_LIBRARY_H
+#define GRPCXX_IMPL_GRPC_LIBRARY_H
+
+#include <grpc/grpc.h>
+
+namespace grpc {
+
+class GrpcLibrary {
+ public:
+ GrpcLibrary() { grpc_init(); }
+ virtual ~GrpcLibrary() { grpc_shutdown(); }
+};
+
+} // namespace grpc
+
+
+#endif // GRPCXX_IMPL_GRPC_LIBRARY_H
diff --git a/include/grpc++/server.h b/include/grpc++/server.h
index eb50611573..0ae27e9e9f 100644
--- a/include/grpc++/server.h
+++ b/include/grpc++/server.h
@@ -40,6 +40,7 @@
#include <grpc++/completion_queue.h>
#include <grpc++/config.h>
#include <grpc++/impl/call.h>
+#include <grpc++/impl/grpc_library.h>
#include <grpc++/impl/service_type.h>
#include <grpc++/impl/sync.h>
#include <grpc++/status.h>
@@ -56,7 +57,8 @@ class ServerCredentials;
class ThreadPoolInterface;
// Currently it only supports handling rpcs in a single thread.
-class Server GRPC_FINAL : private CallHook,
+class Server GRPC_FINAL : public GrpcLibrary,
+ private CallHook,
private AsynchronousService::DispatchImpl {
public:
~Server();
diff --git a/src/cpp/client/channel.h b/src/cpp/client/channel.h
index aaf4dbe10d..cd239247c8 100644
--- a/src/cpp/client/channel.h
+++ b/src/cpp/client/channel.h
@@ -38,6 +38,7 @@
#include <grpc++/channel_interface.h>
#include <grpc++/config.h>
+#include <grpc++/impl/grpc_library.h>
struct grpc_channel;
@@ -49,7 +50,8 @@ class CompletionQueue;
class Credentials;
class StreamContextInterface;
-class Channel GRPC_FINAL : public ChannelInterface {
+class Channel GRPC_FINAL : public GrpcLibrary,
+ public ChannelInterface {
public:
Channel(const grpc::string& target, grpc_channel* c_channel);
~Channel() GRPC_OVERRIDE;
diff --git a/test/cpp/client/credentials_test.cc b/test/cpp/client/credentials_test.cc
index 24251f297b..883f1dca7b 100644
--- a/test/cpp/client/credentials_test.cc
+++ b/test/cpp/client/credentials_test.cc
@@ -56,8 +56,6 @@ TEST_F(CredentialsTest, InvalidServiceAccountCreds) {
int main(int argc, char** argv) {
::testing::InitGoogleTest(&argc, argv);
- grpc_init();
int ret = RUN_ALL_TESTS();
- grpc_shutdown();
return ret;
}
diff --git a/test/cpp/end2end/async_end2end_test.cc b/test/cpp/end2end/async_end2end_test.cc
index dd294d9516..e3cbfd6f8d 100644
--- a/test/cpp/end2end/async_end2end_test.cc
+++ b/test/cpp/end2end/async_end2end_test.cc
@@ -595,9 +595,6 @@ TEST_F(AsyncEnd2endTest, MetadataRpc) {
int main(int argc, char** argv) {
grpc_test_init(argc, argv);
- grpc_init();
::testing::InitGoogleTest(&argc, argv);
- int result = RUN_ALL_TESTS();
- grpc_shutdown();
- return result;
+ return RUN_ALL_TESTS();
}
diff --git a/test/cpp/end2end/end2end_test.cc b/test/cpp/end2end/end2end_test.cc
index 2d3b405d1c..f63854ccf3 100644
--- a/test/cpp/end2end/end2end_test.cc
+++ b/test/cpp/end2end/end2end_test.cc
@@ -562,9 +562,6 @@ TEST_F(End2endTest, ClientCancelsBidi) {
int main(int argc, char** argv) {
grpc_test_init(argc, argv);
- grpc_init();
::testing::InitGoogleTest(&argc, argv);
- int result = RUN_ALL_TESTS();
- grpc_shutdown();
- return result;
+ return RUN_ALL_TESTS();
}
diff --git a/test/cpp/end2end/generic_end2end_test.cc b/test/cpp/end2end/generic_end2end_test.cc
index 584d4bc7ba..e70a1cb68b 100644
--- a/test/cpp/end2end/generic_end2end_test.cc
+++ b/test/cpp/end2end/generic_end2end_test.cc
@@ -280,9 +280,6 @@ TEST_F(GenericEnd2endTest, SimpleBidiStreaming) {
int main(int argc, char** argv) {
grpc_test_init(argc, argv);
- grpc_init();
::testing::InitGoogleTest(&argc, argv);
- int result = RUN_ALL_TESTS();
- grpc_shutdown();
- return result;
+ return RUN_ALL_TESTS();
}
diff --git a/test/cpp/interop/client.cc b/test/cpp/interop/client.cc
index 42d16f2f85..072968f7cd 100644
--- a/test/cpp/interop/client.cc
+++ b/test/cpp/interop/client.cc
@@ -76,8 +76,6 @@ using grpc::testing::CreateChannelForTestCase;
using grpc::testing::GetServiceAccountJsonKey;
int main(int argc, char** argv) {
- grpc_init();
-
grpc::testing::InitTest(&argc, &argv, true);
int ret = 0;
@@ -129,8 +127,6 @@ int main(int argc, char** argv) {
FLAGS_test_case.c_str());
ret = 1;
}
- client.Reset(nullptr);
- grpc_shutdown();
return ret;
}
diff --git a/test/cpp/interop/server.cc b/test/cpp/interop/server.cc
index 7888102837..22b8910a24 100644
--- a/test/cpp/interop/server.cc
+++ b/test/cpp/interop/server.cc
@@ -218,13 +218,11 @@ void RunServer() {
static void sigint_handler(int x) { got_sigint = true; }
int main(int argc, char** argv) {
- grpc_init();
grpc::testing::InitTest(&argc, &argv, true);
signal(SIGINT, sigint_handler);
GPR_ASSERT(FLAGS_port != 0);
RunServer();
- grpc_shutdown();
return 0;
}
diff --git a/test/cpp/qps/qps_driver.cc b/test/cpp/qps/qps_driver.cc
index 0669ccf808..93b1247d73 100644
--- a/test/cpp/qps/qps_driver.cc
+++ b/test/cpp/qps/qps_driver.cc
@@ -69,7 +69,6 @@ using grpc::testing::RpcType;
using grpc::testing::ResourceUsage;
int main(int argc, char** argv) {
- grpc_init();
grpc::testing::InitTest(&argc, &argv, true);
RpcType rpc_type;
@@ -104,6 +103,5 @@ int main(int argc, char** argv) {
ReportLatency(result);
ReportTimes(result);
- grpc_shutdown();
return 0;
}
diff --git a/test/cpp/qps/smoke_test.cc b/test/cpp/qps/smoke_test.cc
index 9531913b00..e390730832 100644
--- a/test/cpp/qps/smoke_test.cc
+++ b/test/cpp/qps/smoke_test.cc
@@ -136,14 +136,11 @@ static void RunQPS() {
} // namespace grpc
int main(int argc, char** argv) {
- grpc_init();
-
using namespace grpc::testing;
RunSynchronousStreamingPingPong();
RunSynchronousUnaryPingPong();
RunAsyncUnaryPingPong();
RunQPS();
- grpc_shutdown();
return 0;
}
diff --git a/test/cpp/qps/worker.cc b/test/cpp/qps/worker.cc
index 896a85cc59..281c617382 100644
--- a/test/cpp/qps/worker.cc
+++ b/test/cpp/qps/worker.cc
@@ -64,13 +64,11 @@ static void RunServer() {
} // namespace grpc
int main(int argc, char** argv) {
- grpc_init();
grpc::testing::InitTest(&argc, &argv, true);
signal(SIGINT, sigint_handler);
grpc::testing::RunServer();
-
- grpc_shutdown();
+
return 0;
}
diff --git a/test/cpp/util/cli_call_test.cc b/test/cpp/util/cli_call_test.cc
index 32ef392cc4..457a5e77de 100644
--- a/test/cpp/util/cli_call_test.cc
+++ b/test/cpp/util/cli_call_test.cc
@@ -123,9 +123,6 @@ TEST_F(CliCallTest, SimpleRpc) {
int main(int argc, char** argv) {
grpc_test_init(argc, argv);
- grpc_init();
::testing::InitGoogleTest(&argc, argv);
- int result = RUN_ALL_TESTS();
- grpc_shutdown();
- return result;
+ return RUN_ALL_TESTS();
}
diff --git a/test/cpp/util/grpc_cli.cc b/test/cpp/util/grpc_cli.cc
index ee9f275273..d71a7a0b77 100644
--- a/test/cpp/util/grpc_cli.cc
+++ b/test/cpp/util/grpc_cli.cc
@@ -79,8 +79,6 @@ DEFINE_string(output_binary_file, "output.bin",
"Path to output file to write serialized response.");
int main(int argc, char** argv) {
- grpc_init();
-
grpc::testing::InitTest(&argc, &argv, true);
if (argc < 4 || grpc::string(argv[1]) != "call") {
@@ -127,7 +125,5 @@ int main(int argc, char** argv) {
output_file << response;
}
- channel.reset();
- grpc_shutdown();
return 0;
}
diff --git a/vsprojects/grpc++/grpc++.vcxproj b/vsprojects/grpc++/grpc++.vcxproj
index 38eca1a14e..07c018f111 100644
--- a/vsprojects/grpc++/grpc++.vcxproj
+++ b/vsprojects/grpc++/grpc++.vcxproj
@@ -96,6 +96,7 @@
<ClInclude Include="..\..\include\grpc++\generic_stub.h" />
<ClInclude Include="..\..\include\grpc++\impl\call.h" />
<ClInclude Include="..\..\include\grpc++\impl\client_unary_call.h" />
+ <ClInclude Include="..\..\include\grpc++\impl\grpc_library.h" />
<ClInclude Include="..\..\include\grpc++\impl\internal_stub.h" />
<ClInclude Include="..\..\include\grpc++\impl\rpc_method.h" />
<ClInclude Include="..\..\include\grpc++\impl\rpc_service_method.h" />
diff --git a/vsprojects/grpc++/grpc++.vcxproj.filters b/vsprojects/grpc++/grpc++.vcxproj.filters
index 6466a0fa26..46b33bb8a6 100644
--- a/vsprojects/grpc++/grpc++.vcxproj.filters
+++ b/vsprojects/grpc++/grpc++.vcxproj.filters
@@ -120,6 +120,9 @@
<ClInclude Include="..\..\include\grpc++\impl\client_unary_call.h">
<Filter>include\grpc++\impl</Filter>
</ClInclude>
+ <ClInclude Include="..\..\include\grpc++\impl\grpc_library.h">
+ <Filter>include\grpc++\impl</Filter>
+ </ClInclude>
<ClInclude Include="..\..\include\grpc++\impl\internal_stub.h">
<Filter>include\grpc++\impl</Filter>
</ClInclude>