aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar vjpai <vpai@google.com>2015-06-01 09:41:09 -0700
committerGravatar vjpai <vpai@google.com>2015-06-01 09:41:09 -0700
commit1795985322eb8b4e689c5e175d9d6937839f817c (patch)
treed3ce282d12ea0920ca94a9da9509ec6704f4dfa4 /src
parent675140ca1d394f564f2156add8a1a18a2dc132b7 (diff)
parent7f61193cdeacfb21f4e99ac6b8e2c0da33a643e8 (diff)
Merge branch 'master' into poisson
Diffstat (limited to 'src')
-rw-r--r--src/compiler/objective_c_generator.cc63
-rw-r--r--src/compiler/objective_c_generator.h9
-rw-r--r--src/compiler/objective_c_generator_helpers.h12
-rw-r--r--src/compiler/objective_c_plugin.cc4
-rw-r--r--src/core/channel/context.h7
-rw-r--r--src/core/iomgr/fd_posix.c6
-rw-r--r--src/core/iomgr/pollset_multipoller_with_epoll.c9
-rw-r--r--src/core/iomgr/pollset_multipoller_with_poll_posix.c14
-rw-r--r--src/core/iomgr/pollset_posix.h11
-rw-r--r--src/core/security/auth_filters.h (renamed from src/core/security/auth.h)7
-rw-r--r--src/core/security/client_auth_filter.c (renamed from src/core/security/auth.c)26
-rw-r--r--src/core/security/credentials.c216
-rw-r--r--src/core/security/credentials.h41
-rw-r--r--src/core/security/credentials_metadata.c101
-rw-r--r--src/core/security/security_connector.c75
-rw-r--r--src/core/security/security_connector.h1
-rw-r--r--src/core/security/security_context.c150
-rw-r--r--src/core/security/security_context.h48
-rw-r--r--src/core/security/server_auth_filter.c128
-rw-r--r--src/core/security/server_secure_chttp2.c25
-rw-r--r--src/core/support/cmdline.c70
-rw-r--r--src/core/surface/call.c18
-rw-r--r--src/core/surface/secure_channel_create.c4
-rw-r--r--src/core/surface/server.c6
-rw-r--r--src/core/surface/server.h2
-rw-r--r--src/core/surface/server_chttp2.c3
-rw-r--r--src/core/transport/metadata.h2
-rw-r--r--src/core/transport/transport.h3
-rw-r--r--src/cpp/server/server.cc4
-rw-r--r--src/csharp/Grpc.Auth/Grpc.Auth.nuspec2
-rw-r--r--src/csharp/Grpc.Core/Grpc.Core.nuspec2
-rw-r--r--src/csharp/Grpc.Tools.nuspec22
-rw-r--r--src/csharp/Grpc.nuspec4
-rw-r--r--src/csharp/README.md23
-rw-r--r--src/csharp/build_packages.bat1
-rw-r--r--src/objective-c/GRPCClient/private/GRPCSecureChannel.m18
-rw-r--r--src/objective-c/README.md6
-rw-r--r--src/objective-c/examples/Sample/Podfile8
-rw-r--r--src/objective-c/examples/Sample/Sample.xcodeproj/project.pbxproj185
-rw-r--r--src/objective-c/examples/Sample/Sample/AppDelegate.h3
-rw-r--r--src/objective-c/examples/Sample/Sample/AppDelegate.m8
-rw-r--r--src/objective-c/examples/Sample/Sample/Base.lproj/LaunchScreen.xib41
-rw-r--r--src/objective-c/examples/Sample/Sample/Base.lproj/Main.storyboard38
-rw-r--r--src/objective-c/examples/Sample/Sample/Info.plist2
-rw-r--r--src/objective-c/examples/Sample/Sample/ViewController.m3
-rw-r--r--src/objective-c/generated_libraries/RemoteTestClient/Empty.pbobjc.h (renamed from src/objective-c/examples/Sample/RemoteTestClient/Empty.pbobjc.h)0
-rw-r--r--src/objective-c/generated_libraries/RemoteTestClient/Empty.pbobjc.m (renamed from src/objective-c/examples/Sample/RemoteTestClient/Empty.pbobjc.m)0
-rw-r--r--src/objective-c/generated_libraries/RemoteTestClient/Messages.pbobjc.h (renamed from src/objective-c/examples/Sample/RemoteTestClient/Messages.pbobjc.h)0
-rw-r--r--src/objective-c/generated_libraries/RemoteTestClient/Messages.pbobjc.m (renamed from src/objective-c/examples/Sample/RemoteTestClient/Messages.pbobjc.m)0
-rw-r--r--src/objective-c/generated_libraries/RemoteTestClient/RemoteTest.podspec (renamed from src/objective-c/examples/Sample/RemoteTestClient/RemoteTest.podspec)0
-rw-r--r--src/objective-c/generated_libraries/RemoteTestClient/Test.pbobjc.h (renamed from src/objective-c/examples/Sample/RemoteTestClient/Test.pbobjc.h)0
-rw-r--r--src/objective-c/generated_libraries/RemoteTestClient/Test.pbobjc.m (renamed from src/objective-c/examples/Sample/RemoteTestClient/Test.pbobjc.m)0
-rw-r--r--src/objective-c/generated_libraries/RemoteTestClient/Test.pbrpc.h (renamed from src/objective-c/examples/Sample/RemoteTestClient/Test.pbrpc.h)0
-rw-r--r--src/objective-c/generated_libraries/RemoteTestClient/Test.pbrpc.m (renamed from src/objective-c/examples/Sample/RemoteTestClient/Test.pbrpc.m)0
-rw-r--r--src/objective-c/generated_libraries/RemoteTestClient/empty.proto (renamed from src/objective-c/examples/Sample/RemoteTestClient/empty.proto)0
-rw-r--r--src/objective-c/generated_libraries/RemoteTestClient/messages.proto (renamed from src/objective-c/examples/Sample/RemoteTestClient/messages.proto)0
-rw-r--r--src/objective-c/generated_libraries/RemoteTestClient/test.proto (renamed from src/objective-c/examples/Sample/RemoteTestClient/test.proto)0
-rw-r--r--src/objective-c/generated_libraries/RouteGuideClient/RouteGuide.pbobjc.h (renamed from src/objective-c/examples/Sample/RouteGuideClient/RouteGuide.pbobjc.h)0
-rw-r--r--src/objective-c/generated_libraries/RouteGuideClient/RouteGuide.pbobjc.m (renamed from src/objective-c/examples/Sample/RouteGuideClient/RouteGuide.pbobjc.m)0
-rw-r--r--src/objective-c/generated_libraries/RouteGuideClient/RouteGuide.pbrpc.h (renamed from src/objective-c/examples/Sample/RouteGuideClient/RouteGuide.pbrpc.h)0
-rw-r--r--src/objective-c/generated_libraries/RouteGuideClient/RouteGuide.pbrpc.m (renamed from src/objective-c/examples/Sample/RouteGuideClient/RouteGuide.pbrpc.m)0
-rw-r--r--src/objective-c/generated_libraries/RouteGuideClient/Route_guide.podspec (renamed from src/objective-c/examples/Sample/RouteGuideClient/Route_guide.podspec)0
-rw-r--r--src/objective-c/generated_libraries/RouteGuideClient/route_guide.proto (renamed from src/objective-c/examples/Sample/RouteGuideClient/route_guide.proto)0
-rw-r--r--src/objective-c/tests/GRPCClientTests.m (renamed from src/objective-c/examples/Sample/SampleTests/RemoteTests.m)7
-rw-r--r--src/objective-c/tests/Info.plist (renamed from src/objective-c/examples/Sample/SampleTests/Info.plist)2
-rw-r--r--src/objective-c/tests/InteropTests.m (renamed from src/objective-c/examples/Sample/SampleTests/RemoteProtoTests.m)14
-rw-r--r--src/objective-c/tests/LocalClearTextTests.m (renamed from src/objective-c/examples/Sample/SampleTests/SampleTests.m)11
-rw-r--r--src/objective-c/tests/Podfile15
-rw-r--r--src/objective-c/tests/RxLibraryUnitTests.m140
-rw-r--r--src/objective-c/tests/Tests.m40
-rw-r--r--src/objective-c/tests/Tests.xcodeproj/project.pbxproj442
-rw-r--r--src/objective-c/tests/Tests.xcodeproj/project.xcworkspace/contents.xcworkspacedata7
-rwxr-xr-xsrc/php/bin/run_gen_code_test.sh4
-rw-r--r--src/python/interop/interop/_insecure_interop_test.py2
-rw-r--r--src/python/interop/interop/_interop_test_case.py6
-rw-r--r--src/python/interop/interop/_secure_interop_test.py2
-rw-r--r--src/python/interop/interop/methods.py54
-rw-r--r--src/python/src/grpc/_adapter/_blocking_invocation_inline_service_test.py2
-rw-r--r--src/python/src/grpc/_adapter/_c_test.py2
-rw-r--r--src/python/src/grpc/_adapter/_event_invocation_synchronous_event_service_test.py2
-rw-r--r--src/python/src/grpc/_adapter/_future_invocation_asynchronous_event_service_test.py2
-rw-r--r--src/python/src/grpc/_adapter/_links_test.py2
-rw-r--r--src/python/src/grpc/_adapter/_lonely_rear_link_test.py2
-rw-r--r--src/python/src/grpc/_adapter/_low_test.py2
-rw-r--r--src/python/src/grpc/early_adopter/implementations_test.py2
-rw-r--r--src/python/src/grpc/framework/base/implementations_test.py2
-rw-r--r--src/python/src/grpc/framework/face/blocking_invocation_inline_service_test.py2
-rw-r--r--src/python/src/grpc/framework/face/event_invocation_synchronous_event_service_test.py2
-rw-r--r--src/python/src/grpc/framework/face/future_invocation_asynchronous_event_service_test.py2
-rw-r--r--src/python/src/grpc/framework/foundation/_later_test.py2
-rw-r--r--src/python/src/grpc/framework/foundation/_logging_pool_test.py2
-rwxr-xr-xsrc/ruby/bin/interop/interop_server.rb7
-rw-r--r--src/ruby/lib/grpc/generic/active_call.rb1
-rw-r--r--src/ruby/lib/grpc/generic/bidi_call.rb28
-rw-r--r--src/ruby/lib/grpc/generic/rpc_desc.rb1
95 files changed, 1638 insertions, 604 deletions
diff --git a/src/compiler/objective_c_generator.cc b/src/compiler/objective_c_generator.cc
index 1bf0254f5b..b235911479 100644
--- a/src/compiler/objective_c_generator.cc
+++ b/src/compiler/objective_c_generator.cc
@@ -32,19 +32,20 @@
*/
#include <map>
+#include <sstream>
+#include "src/compiler/config.h"
#include "src/compiler/objective_c_generator.h"
#include "src/compiler/objective_c_generator_helpers.h"
-#include "src/compiler/config.h"
-
-#include <sstream>
+#include <google/protobuf/compiler/objectivec/objectivec_helpers.h>
+using ::google::protobuf::compiler::objectivec::ClassName;
using ::grpc::protobuf::io::Printer;
using ::grpc::protobuf::MethodDescriptor;
using ::grpc::protobuf::ServiceDescriptor;
-using ::std::map;
using ::grpc::string;
+using ::std::map;
namespace grpc_objective_c_generator {
namespace {
@@ -69,7 +70,7 @@ void PrintMethodSignature(Printer *printer,
if (method->client_streaming()) {
printer->Print("RequestsWriter:(id<GRXWriter>)request");
} else {
- printer->Print(vars, "Request:($prefix$$request_type$ *)request");
+ printer->Print(vars, "Request:($request_class$ *)request");
}
// TODO(jcanizales): Put this on a new line and align colons.
@@ -78,8 +79,7 @@ void PrintMethodSignature(Printer *printer,
if (method->server_streaming()) {
printer->Print("BOOL done, ");
}
- printer->Print(vars,
- "$prefix$$response_type$ *response, NSError *error))handler");
+ printer->Print(vars, "$response_class$ *response, NSError *error))handler");
}
void PrintSimpleSignature(Printer *printer,
@@ -99,12 +99,17 @@ void PrintAdvancedSignature(Printer *printer,
PrintMethodSignature(printer, method, vars);
}
+inline map<string, string> GetMethodVars(const MethodDescriptor *method) {
+ return {{ "method_name", method->name() },
+ { "request_type", method->input_type()->name() },
+ { "response_type", method->output_type()->name() },
+ { "request_class", ClassName(method->input_type()) },
+ { "response_class", ClassName(method->output_type()) }};
+}
+
void PrintMethodDeclarations(Printer *printer,
- const MethodDescriptor *method,
- map<string, string> vars) {
- vars["method_name"] = method->name();
- vars["request_type"] = method->input_type()->name();
- vars["response_type"] = method->output_type()->name();
+ const MethodDescriptor *method) {
+ map<string, string> vars = GetMethodVars(method);
PrintProtoRpcDeclarationAsPragma(printer, method, vars);
@@ -141,8 +146,7 @@ void PrintAdvancedImplementation(Printer *printer,
printer->Print("[GRXWriter writerWithValue:request]\n");
}
- printer->Print(vars,
- " responseClass:[$prefix$$response_type$ class]\n");
+ printer->Print(vars, " responseClass:[$response_class$ class]\n");
printer->Print(" responsesWriteable:[GRXWriteable ");
if (method->server_streaming()) {
@@ -155,11 +159,8 @@ void PrintAdvancedImplementation(Printer *printer,
}
void PrintMethodImplementations(Printer *printer,
- const MethodDescriptor *method,
- map<string, string> vars) {
- vars["method_name"] = method->name();
- vars["request_type"] = method->input_type()->name();
- vars["response_type"] = method->output_type()->name();
+ const MethodDescriptor *method) {
+ map<string, string> vars = GetMethodVars(method);
PrintProtoRpcDeclarationAsPragma(printer, method, vars);
@@ -174,7 +175,7 @@ void PrintMethodImplementations(Printer *printer,
} // namespace
-string GetHeader(const ServiceDescriptor *service, const string prefix) {
+string GetHeader(const ServiceDescriptor *service) {
string output;
{
// Scope the output stream so it closes and finalizes output to the string.
@@ -184,19 +185,19 @@ string GetHeader(const ServiceDescriptor *service, const string prefix) {
printer.Print("@protocol GRXWriteable;\n");
printer.Print("@protocol GRXWriter;\n\n");
- map<string, string> vars = {{"service_name", service->name()},
- {"prefix", prefix}};
- printer.Print(vars, "@protocol $prefix$$service_name$ <NSObject>\n\n");
+ map<string, string> vars = {{"service_class", ServiceClassName(service)}};
+
+ printer.Print(vars, "@protocol $service_class$ <NSObject>\n\n");
for (int i = 0; i < service->method_count(); i++) {
- PrintMethodDeclarations(&printer, service->method(i), vars);
+ PrintMethodDeclarations(&printer, service->method(i));
}
printer.Print("@end\n\n");
printer.Print("// Basic service implementation, over gRPC, that only does"
" marshalling and parsing.\n");
- printer.Print(vars, "@interface $prefix$$service_name$ :"
- " ProtoService<$prefix$$service_name$>\n");
+ printer.Print(vars, "@interface $service_class$ :"
+ " ProtoService<$service_class$>\n");
printer.Print("- (instancetype)initWithHost:(NSString *)host"
" NS_DESIGNATED_INITIALIZER;\n");
printer.Print("@end\n");
@@ -204,7 +205,7 @@ string GetHeader(const ServiceDescriptor *service, const string prefix) {
return output;
}
-string GetSource(const ServiceDescriptor *service, const string prefix) {
+string GetSource(const ServiceDescriptor *service) {
string output;
{
// Scope the output stream so it closes and finalizes output to the string.
@@ -212,15 +213,15 @@ string GetSource(const ServiceDescriptor *service, const string prefix) {
Printer printer(&output_stream, '$');
map<string, string> vars = {{"service_name", service->name()},
- {"package", service->file()->package()},
- {"prefix", prefix}};
+ {"service_class", ServiceClassName(service)},
+ {"package", service->file()->package()}};
printer.Print(vars,
"static NSString *const kPackageName = @\"$package$\";\n");
printer.Print(vars,
"static NSString *const kServiceName = @\"$service_name$\";\n\n");
- printer.Print(vars, "@implementation $prefix$$service_name$\n\n");
+ printer.Print(vars, "@implementation $service_class$\n\n");
printer.Print("// Designated initializer\n");
printer.Print("- (instancetype)initWithHost:(NSString *)host {\n");
@@ -236,7 +237,7 @@ string GetSource(const ServiceDescriptor *service, const string prefix) {
printer.Print("}\n\n\n");
for (int i = 0; i < service->method_count(); i++) {
- PrintMethodImplementations(&printer, service->method(i), vars);
+ PrintMethodImplementations(&printer, service->method(i));
}
printer.Print("@end\n");
diff --git a/src/compiler/objective_c_generator.h b/src/compiler/objective_c_generator.h
index 548e96fcf1..40a0c87f99 100644
--- a/src/compiler/objective_c_generator.h
+++ b/src/compiler/objective_c_generator.h
@@ -38,15 +38,16 @@
namespace grpc_objective_c_generator {
+using ::grpc::protobuf::ServiceDescriptor;
+using ::grpc::string;
+
// Returns the content to be included in the "global_scope" insertion point of
// the generated header file.
-grpc::string GetHeader(const grpc::protobuf::ServiceDescriptor *service,
- const grpc::string prefix);
+string GetHeader(const ServiceDescriptor *service);
// Returns the content to be included in the "global_scope" insertion point of
// the generated implementation file.
-grpc::string GetSource(const grpc::protobuf::ServiceDescriptor *service,
- const grpc::string prefix);
+string GetSource(const ServiceDescriptor *service);
} // namespace grpc_objective_c_generator
diff --git a/src/compiler/objective_c_generator_helpers.h b/src/compiler/objective_c_generator_helpers.h
index d92a2b5e9a..1f8c80014f 100644
--- a/src/compiler/objective_c_generator_helpers.h
+++ b/src/compiler/objective_c_generator_helpers.h
@@ -40,9 +40,19 @@
namespace grpc_objective_c_generator {
-inline grpc::string MessageHeaderName(const grpc::protobuf::FileDescriptor *file) {
+using ::grpc::protobuf::FileDescriptor;
+using ::grpc::protobuf::ServiceDescriptor;
+using ::grpc::string;
+
+inline string MessageHeaderName(const FileDescriptor *file) {
return grpc_generator::FileNameInUpperCamel(file) + ".pbobjc.h";
}
+inline string ServiceClassName(const ServiceDescriptor *service) {
+ const FileDescriptor *file = service->file();
+ string prefix = file->options().objc_class_prefix();
+ return prefix + service->name();
+}
+
}
#endif // GRPC_INTERNAL_COMPILER_OBJECTIVE_C_GENERATOR_HELPERS_H
diff --git a/src/compiler/objective_c_plugin.cc b/src/compiler/objective_c_plugin.cc
index 3cb170e95c..b5ac2bafa9 100644
--- a/src/compiler/objective_c_plugin.cc
+++ b/src/compiler/objective_c_plugin.cc
@@ -77,7 +77,7 @@ class ObjectiveCGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator {
string declarations;
for (int i = 0; i < file->service_count(); i++) {
const grpc::protobuf::ServiceDescriptor *service = file->service(i);
- declarations += grpc_objective_c_generator::GetHeader(service, prefix);
+ declarations += grpc_objective_c_generator::GetHeader(service);
}
Write(context, file_name + ".pbrpc.h",
@@ -95,7 +95,7 @@ class ObjectiveCGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator {
string definitions;
for (int i = 0; i < file->service_count(); i++) {
const grpc::protobuf::ServiceDescriptor *service = file->service(i);
- definitions += grpc_objective_c_generator::GetSource(service, prefix);
+ definitions += grpc_objective_c_generator::GetSource(service);
}
Write(context, file_name + ".pbrpc.m", imports + '\n' + definitions);
diff --git a/src/core/channel/context.h b/src/core/channel/context.h
index e2e5e80513..ac5796b9ef 100644
--- a/src/core/channel/context.h
+++ b/src/core/channel/context.h
@@ -41,4 +41,9 @@ typedef enum {
GRPC_CONTEXT_COUNT
} grpc_context_index;
-#endif
+typedef struct {
+ void *value;
+ void (*destroy)(void *);
+} grpc_call_context_element;
+
+#endif /* GRPC_INTERNAL_CORE_CHANNEL_CONTEXT_H */
diff --git a/src/core/iomgr/fd_posix.c b/src/core/iomgr/fd_posix.c
index 63615ea25f..b697fcc64a 100644
--- a/src/core/iomgr/fd_posix.c
+++ b/src/core/iomgr/fd_posix.c
@@ -165,7 +165,7 @@ static void maybe_wake_one_watcher(grpc_fd *fd) {
gpr_mu_unlock(&fd->watcher_mu);
}
-static void wake_all_watchers(grpc_fd *fd) {
+static void wake_all_watchers_locked(grpc_fd *fd) {
grpc_fd_watcher *watcher;
for (watcher = fd->inactive_watcher_root.next;
watcher != &fd->inactive_watcher_root; watcher = watcher->next) {
@@ -184,7 +184,9 @@ void grpc_fd_orphan(grpc_fd *fd, grpc_iomgr_cb_func on_done, void *user_data) {
fd->on_done_user_data = user_data;
shutdown(fd->fd, SHUT_RDWR);
ref_by(fd, 1); /* remove active status, but keep referenced */
- wake_all_watchers(fd);
+ gpr_mu_lock(&fd->watcher_mu);
+ wake_all_watchers_locked(fd);
+ gpr_mu_unlock(&fd->watcher_mu);
unref_by(fd, 2); /* drop the reference */
}
diff --git a/src/core/iomgr/pollset_multipoller_with_epoll.c b/src/core/iomgr/pollset_multipoller_with_epoll.c
index a1c3938a33..40b7935a57 100644
--- a/src/core/iomgr/pollset_multipoller_with_epoll.c
+++ b/src/core/iomgr/pollset_multipoller_with_epoll.c
@@ -164,8 +164,8 @@ static const grpc_pollset_vtable multipoll_with_epoll_pollset = {
multipoll_with_epoll_pollset_maybe_work, epoll_kick,
multipoll_with_epoll_pollset_destroy};
-void grpc_platform_become_multipoller(grpc_pollset *pollset, grpc_fd **fds,
- size_t nfds) {
+static void epoll_become_multipoller(grpc_pollset *pollset, grpc_fd **fds,
+ size_t nfds) {
size_t i;
pollset_hdr *h = gpr_malloc(sizeof(pollset_hdr));
struct epoll_event ev;
@@ -194,4 +194,7 @@ void grpc_platform_become_multipoller(grpc_pollset *pollset, grpc_fd **fds,
}
}
-#endif /* GPR_LINUX_MULTIPOLL_WITH_EPOLL */
+grpc_platform_become_multipoller_type grpc_platform_become_multipoller =
+ epoll_become_multipoller;
+
+#endif /* GPR_LINUX_MULTIPOLL_WITH_EPOLL */
diff --git a/src/core/iomgr/pollset_multipoller_with_poll_posix.c b/src/core/iomgr/pollset_multipoller_with_poll_posix.c
index 4d36107ab0..d781c9b4bb 100644
--- a/src/core/iomgr/pollset_multipoller_with_poll_posix.c
+++ b/src/core/iomgr/pollset_multipoller_with_poll_posix.c
@@ -33,7 +33,7 @@
#include <grpc/support/port_platform.h>
-#ifdef GPR_POSIX_MULTIPOLL_WITH_POLL
+#ifdef GPR_POSIX_SOCKET
#include "src/core/iomgr/pollset_posix.h"
@@ -98,7 +98,8 @@ static void end_polling(grpc_pollset *pollset) {
pollset_hdr *h;
h = pollset->data.ptr;
for (i = 1; i < h->pfd_count; i++) {
- grpc_fd_end_poll(&h->watchers[i], h->pfds[i].revents & POLLIN, h->pfds[i].revents & POLLOUT);
+ grpc_fd_end_poll(&h->watchers[i], h->pfds[i].revents & POLLIN,
+ h->pfds[i].revents & POLLOUT);
}
}
@@ -228,8 +229,8 @@ static const grpc_pollset_vtable multipoll_with_poll_pollset = {
multipoll_with_poll_pollset_maybe_work, multipoll_with_poll_pollset_kick,
multipoll_with_poll_pollset_destroy};
-void grpc_platform_become_multipoller(grpc_pollset *pollset, grpc_fd **fds,
- size_t nfds) {
+void grpc_poll_become_multipoller(grpc_pollset *pollset, grpc_fd **fds,
+ size_t nfds) {
size_t i;
pollset_hdr *h = gpr_malloc(sizeof(pollset_hdr));
pollset->vtable = &multipoll_with_poll_pollset;
@@ -250,4 +251,9 @@ void grpc_platform_become_multipoller(grpc_pollset *pollset, grpc_fd **fds,
}
}
+#endif /* GPR_POSIX_SOCKET */
+
+#ifdef GPR_POSIX_MULTIPOLL_WITH_POLL
+grpc_platform_become_multipoller_type grpc_platform_become_multipoller =
+ grpc_poll_become_multipoller;
#endif
diff --git a/src/core/iomgr/pollset_posix.h b/src/core/iomgr/pollset_posix.h
index da843f7381..088ec910c2 100644
--- a/src/core/iomgr/pollset_posix.h
+++ b/src/core/iomgr/pollset_posix.h
@@ -101,7 +101,12 @@ void grpc_kick_drain(grpc_pollset *p);
grpc_pollset *grpc_backup_pollset(void);
/* turn a pollset into a multipoller: platform specific */
-void grpc_platform_become_multipoller(grpc_pollset *pollset,
- struct grpc_fd **fds, size_t fd_count);
+typedef void (*grpc_platform_become_multipoller_type)(grpc_pollset *pollset,
+ struct grpc_fd **fds,
+ size_t fd_count);
+extern grpc_platform_become_multipoller_type grpc_platform_become_multipoller;
-#endif /* GRPC_INTERNAL_CORE_IOMGR_POLLSET_POSIX_H */
+void grpc_poll_become_multipoller(grpc_pollset *pollset, struct grpc_fd **fds,
+ size_t fd_count);
+
+#endif /* GRPC_INTERNAL_CORE_IOMGR_POLLSET_POSIX_H */
diff --git a/src/core/security/auth.h b/src/core/security/auth_filters.h
index 08dc4152ba..ff921690e0 100644
--- a/src/core/security/auth.h
+++ b/src/core/security/auth_filters.h
@@ -31,11 +31,12 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_SECURITY_AUTH_H
-#define GRPC_INTERNAL_CORE_SECURITY_AUTH_H
+#ifndef GRPC_INTERNAL_CORE_SECURITY_AUTH_FILTERS_H
+#define GRPC_INTERNAL_CORE_SECURITY_AUTH_FILTERS_H
#include "src/core/channel/channel_stack.h"
extern const grpc_channel_filter grpc_client_auth_filter;
+extern const grpc_channel_filter grpc_server_auth_filter;
-#endif /* GRPC_INTERNAL_CORE_SECURITY_AUTH_H */
+#endif /* GRPC_INTERNAL_CORE_SECURITY_AUTH_FILTERS_H */
diff --git a/src/core/security/auth.c b/src/core/security/client_auth_filter.c
index faf12d8f14..b2bce1fd32 100644
--- a/src/core/security/auth.c
+++ b/src/core/security/client_auth_filter.c
@@ -31,7 +31,7 @@
*
*/
-#include "src/core/security/auth.h"
+#include "src/core/security/auth_filters.h"
#include <string.h>
@@ -77,11 +77,13 @@ static void bubble_up_error(grpc_call_element *elem, const char *error_msg) {
grpc_call_next_op(elem, &calld->op);
}
-static void on_credentials_metadata(void *user_data, grpc_mdelem **md_elems,
+static void on_credentials_metadata(void *user_data,
+ grpc_credentials_md *md_elems,
size_t num_md,
grpc_credentials_status status) {
grpc_call_element *elem = (grpc_call_element *)user_data;
call_data *calld = elem->call_data;
+ channel_data *chand = elem->channel_data;
grpc_transport_op *op = &calld->op;
grpc_metadata_batch *mdb;
size_t i;
@@ -94,8 +96,10 @@ static void on_credentials_metadata(void *user_data, grpc_mdelem **md_elems,
op->send_ops->ops[calld->op_md_idx].type == GRPC_OP_METADATA);
mdb = &op->send_ops->ops[calld->op_md_idx].data.metadata;
for (i = 0; i < num_md; i++) {
- grpc_metadata_batch_add_tail(mdb, &calld->md_links[i],
- grpc_mdelem_ref(md_elems[i]));
+ grpc_metadata_batch_add_tail(
+ mdb, &calld->md_links[i],
+ grpc_mdelem_from_slices(chand->md_ctx, gpr_slice_ref(md_elems[i].key),
+ gpr_slice_ref(md_elems[i].value)));
}
grpc_call_next_op(elem, op);
}
@@ -125,7 +129,7 @@ static void send_security_metadata(grpc_call_element *elem,
call_data *calld = elem->call_data;
channel_data *chand = elem->channel_data;
grpc_client_security_context *ctx =
- (grpc_client_security_context *)op->context[GRPC_CONTEXT_SECURITY];
+ (grpc_client_security_context *)op->context[GRPC_CONTEXT_SECURITY].value;
char *service_url = NULL;
grpc_credentials *channel_creds =
chand->security_connector->request_metadata_creds;
@@ -189,6 +193,8 @@ static void auth_start_transport_op(grpc_call_element *elem,
grpc_linked_mdelem *l;
size_t i;
+ /* TODO(jboeuf): write the call auth context. */
+
if (op->send_ops && !calld->sent_initial_metadata) {
size_t nops = op->send_ops->nops;
grpc_stream_op *ops = op->send_ops->ops;
@@ -273,7 +279,7 @@ static void init_channel_elem(grpc_channel_element *elem,
const grpc_channel_args *args,
grpc_mdctx *metadata_context, int is_first,
int is_last) {
- grpc_security_connector *ctx = grpc_find_security_connector_in_args(args);
+ grpc_security_connector *sc = grpc_find_security_connector_in_args(args);
/* grab pointers to our data from the channel element */
channel_data *chand = elem->channel_data;
@@ -282,12 +288,12 @@ static void init_channel_elem(grpc_channel_element *elem,
path */
GPR_ASSERT(!is_first);
GPR_ASSERT(!is_last);
- GPR_ASSERT(ctx != NULL);
+ GPR_ASSERT(sc != NULL);
/* initialize members */
- GPR_ASSERT(ctx->is_client_side);
+ GPR_ASSERT(sc->is_client_side);
chand->security_connector =
- (grpc_channel_security_connector *)grpc_security_connector_ref(ctx);
+ (grpc_channel_security_connector *)grpc_security_connector_ref(sc);
chand->md_ctx = metadata_context;
chand->authority_string =
grpc_mdstr_from_string(chand->md_ctx, ":authority");
@@ -321,4 +327,4 @@ static void destroy_channel_elem(grpc_channel_element *elem) {
const grpc_channel_filter grpc_client_auth_filter = {
auth_start_transport_op, channel_op, sizeof(call_data), init_call_elem,
destroy_call_elem, sizeof(channel_data), init_channel_elem,
- destroy_channel_elem, "auth"};
+ destroy_channel_elem, "client-auth"};
diff --git a/src/core/security/credentials.c b/src/core/security/credentials.c
index f6366f0750..ae22bf47a0 100644
--- a/src/core/security/credentials.c
+++ b/src/core/security/credentials.c
@@ -114,20 +114,6 @@ void grpc_credentials_get_request_metadata(grpc_credentials *creds,
creds->vtable->get_request_metadata(creds, service_url, cb, user_data);
}
-grpc_mdctx *grpc_credentials_get_or_create_metadata_context(
- grpc_credentials *creds) {
- grpc_mdctx *mdctx = NULL;
- if (creds != NULL && creds->vtable->get_metadata_context != NULL) {
- mdctx = creds->vtable->get_metadata_context(creds);
- }
- if (mdctx == NULL) {
- return grpc_mdctx_create();
- } else {
- grpc_mdctx_ref(mdctx);
- return mdctx;
- }
-}
-
grpc_security_status grpc_credentials_create_security_connector(
grpc_credentials *creds, const char *target, const grpc_channel_args *args,
grpc_credentials *request_metadata_creds,
@@ -208,10 +194,6 @@ static int ssl_has_request_metadata_only(const grpc_credentials *creds) {
return 0;
}
-static grpc_mdctx *ssl_get_metadata_context(grpc_credentials *creds) {
- return NULL;
-}
-
static grpc_security_status ssl_create_security_connector(
grpc_credentials *creds, const char *target, const grpc_channel_args *args,
grpc_credentials *request_metadata_creds,
@@ -249,8 +231,8 @@ static grpc_security_status ssl_server_create_security_connector(
}
static grpc_credentials_vtable ssl_vtable = {
- ssl_destroy, ssl_has_request_metadata, ssl_has_request_metadata_only,
- ssl_get_metadata_context, NULL, ssl_create_security_connector};
+ ssl_destroy, ssl_has_request_metadata, ssl_has_request_metadata_only, NULL,
+ ssl_create_security_connector};
static grpc_server_credentials_vtable ssl_server_vtable = {
ssl_server_destroy, ssl_server_create_security_connector};
@@ -341,13 +323,12 @@ grpc_server_credentials *grpc_ssl_server_credentials_create(
typedef struct {
grpc_credentials base;
- grpc_mdctx *md_ctx;
/* Have a simple cache for now with just 1 entry. We could have a map based on
the service_url for a more sophisticated one. */
gpr_mu cache_mu;
struct {
- grpc_mdelem *jwt_md;
+ grpc_credentials_md_store *jwt_md;
char *service_url;
gpr_timespec jwt_expiration;
} cached;
@@ -358,7 +339,7 @@ typedef struct {
static void jwt_reset_cache(grpc_jwt_credentials *c) {
if (c->cached.jwt_md != NULL) {
- grpc_mdelem_unref(c->cached.jwt_md);
+ grpc_credentials_md_store_unref(c->cached.jwt_md);
c->cached.jwt_md = NULL;
}
if (c->cached.service_url != NULL) {
@@ -373,7 +354,6 @@ static void jwt_destroy(grpc_credentials *creds) {
grpc_auth_json_key_destruct(&c->key);
jwt_reset_cache(c);
gpr_mu_destroy(&c->cache_mu);
- grpc_mdctx_unref(c->md_ctx);
gpr_free(c);
}
@@ -393,7 +373,7 @@ static void jwt_get_request_metadata(grpc_credentials *creds,
0};
/* See if we can return a cached jwt. */
- grpc_mdelem *jwt_md = NULL;
+ grpc_credentials_md_store *jwt_md = NULL;
{
gpr_mu_lock(&c->cache_mu);
if (c->cached.service_url != NULL &&
@@ -401,7 +381,7 @@ static void jwt_get_request_metadata(grpc_credentials *creds,
c->cached.jwt_md != NULL &&
(gpr_time_cmp(gpr_time_sub(c->cached.jwt_expiration, gpr_now()),
refresh_threshold) > 0)) {
- jwt_md = grpc_mdelem_ref(c->cached.jwt_md);
+ jwt_md = grpc_credentials_md_store_ref(c->cached.jwt_md);
}
gpr_mu_unlock(&c->cache_mu);
}
@@ -418,30 +398,26 @@ static void jwt_get_request_metadata(grpc_credentials *creds,
gpr_free(jwt);
c->cached.jwt_expiration = gpr_time_add(gpr_now(), c->jwt_lifetime);
c->cached.service_url = gpr_strdup(service_url);
- c->cached.jwt_md = grpc_mdelem_from_strings(
- c->md_ctx, GRPC_AUTHORIZATION_METADATA_KEY, md_value);
+ c->cached.jwt_md = grpc_credentials_md_store_create(1);
+ grpc_credentials_md_store_add_cstrings(
+ c->cached.jwt_md, GRPC_AUTHORIZATION_METADATA_KEY, md_value);
gpr_free(md_value);
- jwt_md = grpc_mdelem_ref(c->cached.jwt_md);
+ jwt_md = grpc_credentials_md_store_ref(c->cached.jwt_md);
}
gpr_mu_unlock(&c->cache_mu);
}
if (jwt_md != NULL) {
- cb(user_data, &jwt_md, 1, GRPC_CREDENTIALS_OK);
- grpc_mdelem_unref(jwt_md);
+ cb(user_data, jwt_md->entries, jwt_md->num_entries, GRPC_CREDENTIALS_OK);
+ grpc_credentials_md_store_unref(jwt_md);
} else {
cb(user_data, NULL, 0, GRPC_CREDENTIALS_ERROR);
}
}
-static grpc_mdctx *jwt_get_metadata_context(grpc_credentials *creds) {
- grpc_jwt_credentials *c = (grpc_jwt_credentials *)creds;
- return c->md_ctx;
-}
-
static grpc_credentials_vtable jwt_vtable = {
jwt_destroy, jwt_has_request_metadata, jwt_has_request_metadata_only,
- jwt_get_metadata_context, jwt_get_request_metadata, NULL};
+ jwt_get_request_metadata, NULL};
grpc_credentials *grpc_jwt_credentials_create(const char *json_key,
gpr_timespec token_lifetime) {
@@ -456,7 +432,6 @@ grpc_credentials *grpc_jwt_credentials_create(const char *json_key,
c->base.type = GRPC_CREDENTIALS_TYPE_JWT;
gpr_ref_init(&c->base.refcount, 1);
c->base.vtable = &jwt_vtable;
- c->md_ctx = grpc_mdctx_create();
c->key = key;
c->jwt_lifetime = token_lifetime;
gpr_mu_init(&c->cache_mu);
@@ -476,8 +451,7 @@ typedef void (*grpc_fetch_oauth2_func)(grpc_credentials_metadata_request *req,
typedef struct {
grpc_credentials base;
gpr_mu mu;
- grpc_mdctx *md_ctx;
- grpc_mdelem *access_token_md;
+ grpc_credentials_md_store *access_token_md;
gpr_timespec token_expiration;
grpc_fetch_oauth2_func fetch_func;
} grpc_oauth2_token_fetcher_credentials;
@@ -485,11 +459,8 @@ typedef struct {
static void oauth2_token_fetcher_destroy(grpc_credentials *creds) {
grpc_oauth2_token_fetcher_credentials *c =
(grpc_oauth2_token_fetcher_credentials *)creds;
- if (c->access_token_md != NULL) {
- grpc_mdelem_unref(c->access_token_md);
- }
+ grpc_credentials_md_store_unref(c->access_token_md);
gpr_mu_destroy(&c->mu);
- grpc_mdctx_unref(c->md_ctx);
gpr_free(c);
}
@@ -505,8 +476,8 @@ static int oauth2_token_fetcher_has_request_metadata_only(
grpc_credentials_status
grpc_oauth2_token_fetcher_credentials_parse_server_response(
- const grpc_httpcli_response *response, grpc_mdctx *ctx,
- grpc_mdelem **token_elem, gpr_timespec *token_lifetime) {
+ const grpc_httpcli_response *response,
+ grpc_credentials_md_store **token_md, gpr_timespec *token_lifetime) {
char *null_terminated_body = NULL;
char *new_access_token = NULL;
grpc_credentials_status status = GRPC_CREDENTIALS_OK;
@@ -574,16 +545,17 @@ grpc_oauth2_token_fetcher_credentials_parse_server_response(
access_token->value);
token_lifetime->tv_sec = strtol(expires_in->value, NULL, 10);
token_lifetime->tv_nsec = 0;
- if (*token_elem != NULL) grpc_mdelem_unref(*token_elem);
- *token_elem = grpc_mdelem_from_strings(ctx, GRPC_AUTHORIZATION_METADATA_KEY,
- new_access_token);
+ if (*token_md != NULL) grpc_credentials_md_store_unref(*token_md);
+ *token_md = grpc_credentials_md_store_create(1);
+ grpc_credentials_md_store_add_cstrings(
+ *token_md, GRPC_AUTHORIZATION_METADATA_KEY, new_access_token);
status = GRPC_CREDENTIALS_OK;
}
end:
- if (status != GRPC_CREDENTIALS_OK && (*token_elem != NULL)) {
- grpc_mdelem_unref(*token_elem);
- *token_elem = NULL;
+ if (status != GRPC_CREDENTIALS_OK && (*token_md != NULL)) {
+ grpc_credentials_md_store_unref(*token_md);
+ *token_md = NULL;
}
if (null_terminated_body != NULL) gpr_free(null_terminated_body);
if (new_access_token != NULL) gpr_free(new_access_token);
@@ -602,10 +574,11 @@ static void on_oauth2_token_fetcher_http_response(
gpr_mu_lock(&c->mu);
status = grpc_oauth2_token_fetcher_credentials_parse_server_response(
- response, c->md_ctx, &c->access_token_md, &token_lifetime);
+ response, &c->access_token_md, &token_lifetime);
if (status == GRPC_CREDENTIALS_OK) {
c->token_expiration = gpr_time_add(gpr_now(), token_lifetime);
- r->cb(r->user_data, &c->access_token_md, 1, status);
+ r->cb(r->user_data, c->access_token_md->entries,
+ c->access_token_md->num_entries, status);
} else {
c->token_expiration = gpr_inf_past;
r->cb(r->user_data, NULL, 0, status);
@@ -621,19 +594,20 @@ static void oauth2_token_fetcher_get_request_metadata(
(grpc_oauth2_token_fetcher_credentials *)creds;
gpr_timespec refresh_threshold = {GRPC_SECURE_TOKEN_REFRESH_THRESHOLD_SECS,
0};
- grpc_mdelem *cached_access_token_md = NULL;
+ grpc_credentials_md_store *cached_access_token_md = NULL;
{
gpr_mu_lock(&c->mu);
if (c->access_token_md != NULL &&
(gpr_time_cmp(gpr_time_sub(c->token_expiration, gpr_now()),
refresh_threshold) > 0)) {
- cached_access_token_md = grpc_mdelem_ref(c->access_token_md);
+ cached_access_token_md = grpc_credentials_md_store_ref(c->access_token_md);
}
gpr_mu_unlock(&c->mu);
}
if (cached_access_token_md != NULL) {
- cb(user_data, &cached_access_token_md, 1, GRPC_CREDENTIALS_OK);
- grpc_mdelem_unref(cached_access_token_md);
+ cb(user_data, cached_access_token_md->entries,
+ cached_access_token_md->num_entries, GRPC_CREDENTIALS_OK);
+ grpc_credentials_md_store_unref(cached_access_token_md);
} else {
c->fetch_func(
grpc_credentials_metadata_request_create(creds, cb, user_data),
@@ -648,24 +622,15 @@ static void init_oauth2_token_fetcher(grpc_oauth2_token_fetcher_credentials *c,
c->base.type = GRPC_CREDENTIALS_TYPE_OAUTH2;
gpr_ref_init(&c->base.refcount, 1);
gpr_mu_init(&c->mu);
- c->md_ctx = grpc_mdctx_create();
c->token_expiration = gpr_inf_past;
c->fetch_func = fetch_func;
}
-static grpc_mdctx *oauth2_token_fetcher_get_metadata_context(
- grpc_credentials *creds) {
- grpc_oauth2_token_fetcher_credentials *c =
- (grpc_oauth2_token_fetcher_credentials *)creds;
- return c->md_ctx;
-}
-
/* -- ComputeEngine credentials. -- */
static grpc_credentials_vtable compute_engine_vtable = {
oauth2_token_fetcher_destroy, oauth2_token_fetcher_has_request_metadata,
oauth2_token_fetcher_has_request_metadata_only,
- oauth2_token_fetcher_get_metadata_context,
oauth2_token_fetcher_get_request_metadata, NULL};
static void compute_engine_fetch_oauth2(
@@ -709,7 +674,6 @@ static void service_account_destroy(grpc_credentials *creds) {
static grpc_credentials_vtable service_account_vtable = {
service_account_destroy, oauth2_token_fetcher_has_request_metadata,
oauth2_token_fetcher_has_request_metadata_only,
- oauth2_token_fetcher_get_metadata_context,
oauth2_token_fetcher_get_request_metadata, NULL};
static void service_account_fetch_oauth2(
@@ -783,7 +747,6 @@ static void refresh_token_destroy(grpc_credentials *creds) {
static grpc_credentials_vtable refresh_token_vtable = {
refresh_token_destroy, oauth2_token_fetcher_has_request_metadata,
oauth2_token_fetcher_has_request_metadata_only,
- oauth2_token_fetcher_get_metadata_context,
oauth2_token_fetcher_get_request_metadata, NULL};
static void refresh_token_fetch_oauth2(
@@ -832,17 +795,13 @@ grpc_credentials *grpc_refresh_token_credentials_create(
typedef struct {
grpc_credentials base;
- grpc_mdctx *md_ctx;
- grpc_mdelem *access_token_md;
+ grpc_credentials_md_store *access_token_md;
int is_async;
} grpc_fake_oauth2_credentials;
static void fake_oauth2_destroy(grpc_credentials *creds) {
grpc_fake_oauth2_credentials *c = (grpc_fake_oauth2_credentials *)creds;
- if (c->access_token_md != NULL) {
- grpc_mdelem_unref(c->access_token_md);
- }
- grpc_mdctx_unref(c->md_ctx);
+ grpc_credentials_md_store_unref(c->access_token_md);
gpr_free(c);
}
@@ -860,7 +819,8 @@ void on_simulated_token_fetch_done(void *user_data, int success) {
(grpc_credentials_metadata_request *)user_data;
grpc_fake_oauth2_credentials *c = (grpc_fake_oauth2_credentials *)r->creds;
GPR_ASSERT(success);
- r->cb(r->user_data, &c->access_token_md, 1, GRPC_CREDENTIALS_OK);
+ r->cb(r->user_data, c->access_token_md->entries,
+ c->access_token_md->num_entries, GRPC_CREDENTIALS_OK);
grpc_credentials_metadata_request_destroy(r);
}
@@ -875,19 +835,14 @@ static void fake_oauth2_get_request_metadata(grpc_credentials *creds,
on_simulated_token_fetch_done,
grpc_credentials_metadata_request_create(creds, cb, user_data));
} else {
- cb(user_data, &c->access_token_md, 1, GRPC_CREDENTIALS_OK);
+ cb(user_data, c->access_token_md->entries, 1, GRPC_CREDENTIALS_OK);
}
}
-static grpc_mdctx *fake_oauth2_get_metadata_context(grpc_credentials *creds) {
- grpc_fake_oauth2_credentials *c = (grpc_fake_oauth2_credentials *)creds;
- return c->md_ctx;
-}
-
static grpc_credentials_vtable fake_oauth2_vtable = {
fake_oauth2_destroy, fake_oauth2_has_request_metadata,
- fake_oauth2_has_request_metadata_only, fake_oauth2_get_metadata_context,
- fake_oauth2_get_request_metadata, NULL};
+ fake_oauth2_has_request_metadata_only, fake_oauth2_get_request_metadata,
+ NULL};
grpc_credentials *grpc_fake_oauth2_credentials_create(
const char *token_md_value, int is_async) {
@@ -897,9 +852,9 @@ grpc_credentials *grpc_fake_oauth2_credentials_create(
c->base.type = GRPC_CREDENTIALS_TYPE_OAUTH2;
c->base.vtable = &fake_oauth2_vtable;
gpr_ref_init(&c->base.refcount, 1);
- c->md_ctx = grpc_mdctx_create();
- c->access_token_md = grpc_mdelem_from_strings(
- c->md_ctx, GRPC_AUTHORIZATION_METADATA_KEY, token_md_value);
+ c->access_token_md = grpc_credentials_md_store_create(1);
+ grpc_credentials_md_store_add_cstrings(
+ c->access_token_md, GRPC_AUTHORIZATION_METADATA_KEY, token_md_value);
c->is_async = is_async;
return &c->base;
}
@@ -926,11 +881,6 @@ static int fake_transport_security_has_request_metadata_only(
return 0;
}
-static grpc_mdctx *fake_transport_security_get_metadata_context(
- grpc_credentials *c) {
- return NULL;
-}
-
static grpc_security_status
fake_transport_security_create_security_connector(
grpc_credentials *c, const char *target, const grpc_channel_args *args,
@@ -950,8 +900,7 @@ fake_transport_security_server_create_security_connector(
static grpc_credentials_vtable fake_transport_security_credentials_vtable = {
fake_transport_security_credentials_destroy,
fake_transport_security_has_request_metadata,
- fake_transport_security_has_request_metadata_only,
- fake_transport_security_get_metadata_context, NULL,
+ fake_transport_security_has_request_metadata_only, NULL,
fake_transport_security_create_security_connector};
static grpc_server_credentials_vtable
@@ -988,8 +937,7 @@ typedef struct {
typedef struct {
grpc_composite_credentials *composite_creds;
size_t creds_index;
- grpc_mdelem **md_elems;
- size_t num_md;
+ grpc_credentials_md_store *md_elems;
char *service_url;
void *user_data;
grpc_credentials_metadata_cb cb;
@@ -1031,21 +979,16 @@ static int composite_has_request_metadata_only(const grpc_credentials *creds) {
static void composite_md_context_destroy(
grpc_composite_credentials_metadata_context *ctx) {
- size_t i;
- for (i = 0; i < ctx->num_md; i++) {
- grpc_mdelem_unref(ctx->md_elems[i]);
- }
- gpr_free(ctx->md_elems);
+ grpc_credentials_md_store_unref(ctx->md_elems);
if (ctx->service_url != NULL) gpr_free(ctx->service_url);
gpr_free(ctx);
}
-static void composite_metadata_cb(void *user_data, grpc_mdelem **md_elems,
- size_t num_md,
+static void composite_metadata_cb(void *user_data,
+ grpc_credentials_md *md_elems, size_t num_md,
grpc_credentials_status status) {
grpc_composite_credentials_metadata_context *ctx =
(grpc_composite_credentials_metadata_context *)user_data;
- size_t i;
if (status != GRPC_CREDENTIALS_OK) {
ctx->cb(ctx->user_data, NULL, 0, status);
return;
@@ -1053,12 +996,11 @@ static void composite_metadata_cb(void *user_data, grpc_mdelem **md_elems,
/* Copy the metadata in the context. */
if (num_md > 0) {
- ctx->md_elems = gpr_realloc(ctx->md_elems,
- (ctx->num_md + num_md) * sizeof(grpc_mdelem *));
+ size_t i;
for (i = 0; i < num_md; i++) {
- ctx->md_elems[i + ctx->num_md] = grpc_mdelem_ref(md_elems[i]);
+ grpc_credentials_md_store_add(ctx->md_elems, md_elems[i].key,
+ md_elems[i].value);
}
- ctx->num_md += num_md;
}
/* See if we need to get some more metadata. */
@@ -1073,7 +1015,8 @@ static void composite_metadata_cb(void *user_data, grpc_mdelem **md_elems,
}
/* We're done!. */
- ctx->cb(ctx->user_data, ctx->md_elems, ctx->num_md, GRPC_CREDENTIALS_OK);
+ ctx->cb(ctx->user_data, ctx->md_elems->entries, ctx->md_elems->num_entries,
+ GRPC_CREDENTIALS_OK);
composite_md_context_destroy(ctx);
}
@@ -1093,6 +1036,7 @@ static void composite_get_request_metadata(grpc_credentials *creds,
ctx->user_data = user_data;
ctx->cb = cb;
ctx->composite_creds = c;
+ ctx->md_elems = grpc_credentials_md_store_create(c->inner.num_creds);
while (ctx->creds_index < c->inner.num_creds) {
grpc_credentials *inner_creds = c->inner.creds_array[ctx->creds_index++];
if (grpc_credentials_has_request_metadata(inner_creds)) {
@@ -1104,25 +1048,6 @@ static void composite_get_request_metadata(grpc_credentials *creds,
GPR_ASSERT(0); /* Should have exited before. */
}
-static grpc_mdctx *composite_get_metadata_context(grpc_credentials *creds) {
- grpc_composite_credentials *c = (grpc_composite_credentials *)creds;
- grpc_mdctx *ctx = NULL;
- size_t i;
- for (i = 0; i < c->inner.num_creds; i++) {
- grpc_credentials *inner_creds = c->inner.creds_array[i];
- grpc_mdctx *inner_ctx = NULL;
- if (inner_creds->vtable->get_metadata_context != NULL) {
- inner_ctx = inner_creds->vtable->get_metadata_context(inner_creds);
- }
- if (inner_ctx) {
- GPR_ASSERT(ctx == NULL &&
- "can only have one metadata context per composite credential");
- ctx = inner_ctx;
- }
- }
- return ctx;
-}
-
static grpc_security_status composite_create_security_connector(
grpc_credentials *creds, const char *target, const grpc_channel_args *args,
grpc_credentials *request_metadata_creds,
@@ -1139,8 +1064,8 @@ static grpc_security_status composite_create_security_connector(
static grpc_credentials_vtable composite_credentials_vtable = {
composite_destroy, composite_has_request_metadata,
- composite_has_request_metadata_only, composite_get_metadata_context,
- composite_get_request_metadata, composite_create_security_connector};
+ composite_has_request_metadata_only, composite_get_request_metadata,
+ composite_create_security_connector};
static grpc_credentials_array get_creds_array(grpc_credentials **creds_addr) {
grpc_credentials_array result;
@@ -1237,16 +1162,12 @@ grpc_credentials *grpc_credentials_contains_type(
typedef struct {
grpc_credentials base;
- grpc_mdctx *md_ctx;
- grpc_mdelem *token_md;
- grpc_mdelem *authority_selector_md;
+ grpc_credentials_md_store *iam_md;
} grpc_iam_credentials;
static void iam_destroy(grpc_credentials *creds) {
grpc_iam_credentials *c = (grpc_iam_credentials *)creds;
- grpc_mdelem_unref(c->token_md);
- grpc_mdelem_unref(c->authority_selector_md);
- grpc_mdctx_unref(c->md_ctx);
+ grpc_credentials_md_store_unref(c->iam_md);
gpr_free(c);
}
@@ -1263,20 +1184,13 @@ static void iam_get_request_metadata(grpc_credentials *creds,
grpc_credentials_metadata_cb cb,
void *user_data) {
grpc_iam_credentials *c = (grpc_iam_credentials *)creds;
- grpc_mdelem *md_array[2];
- md_array[0] = c->token_md;
- md_array[1] = c->authority_selector_md;
- cb(user_data, md_array, 2, GRPC_CREDENTIALS_OK);
-}
-
-static grpc_mdctx *iam_get_metadata_context(grpc_credentials *creds) {
- grpc_iam_credentials *c = (grpc_iam_credentials *)creds;
- return c->md_ctx;
+ cb(user_data, c->iam_md->entries, c->iam_md->num_entries,
+ GRPC_CREDENTIALS_OK);
}
static grpc_credentials_vtable iam_vtable = {
iam_destroy, iam_has_request_metadata, iam_has_request_metadata_only,
- iam_get_metadata_context, iam_get_request_metadata, NULL};
+ iam_get_request_metadata, NULL};
grpc_credentials *grpc_iam_credentials_create(const char *token,
const char *authority_selector) {
@@ -1288,10 +1202,10 @@ grpc_credentials *grpc_iam_credentials_create(const char *token,
c->base.type = GRPC_CREDENTIALS_TYPE_IAM;
c->base.vtable = &iam_vtable;
gpr_ref_init(&c->base.refcount, 1);
- c->md_ctx = grpc_mdctx_create();
- c->token_md = grpc_mdelem_from_strings(
- c->md_ctx, GRPC_IAM_AUTHORIZATION_TOKEN_METADATA_KEY, token);
- c->authority_selector_md = grpc_mdelem_from_strings(
- c->md_ctx, GRPC_IAM_AUTHORITY_SELECTOR_METADATA_KEY, authority_selector);
+ c->iam_md = grpc_credentials_md_store_create(2);
+ grpc_credentials_md_store_add_cstrings(
+ c->iam_md, GRPC_IAM_AUTHORIZATION_TOKEN_METADATA_KEY, token);
+ grpc_credentials_md_store_add_cstrings(
+ c->iam_md, GRPC_IAM_AUTHORITY_SELECTOR_METADATA_KEY, authority_selector);
return &c->base;
}
diff --git a/src/core/security/credentials.h b/src/core/security/credentials.h
index 87c773e49a..4768ce6990 100644
--- a/src/core/security/credentials.h
+++ b/src/core/security/credentials.h
@@ -82,13 +82,40 @@ typedef enum {
#define GRPC_REFRESH_TOKEN_POST_BODY_FORMAT_STRING \
"client_id=%s&client_secret=%s&refresh_token=%s&grant_type=refresh_token"
+/* --- grpc_credentials_md. --- */
+
+typedef struct {
+ gpr_slice key;
+ gpr_slice value;
+} grpc_credentials_md;
+
+typedef struct {
+ grpc_credentials_md *entries;
+ size_t num_entries;
+ size_t allocated;
+ gpr_refcount refcount;
+} grpc_credentials_md_store;
+
+grpc_credentials_md_store *grpc_credentials_md_store_create(
+ size_t initial_capacity);
+
+/* Will ref key and value. */
+void grpc_credentials_md_store_add(grpc_credentials_md_store *store,
+ gpr_slice key, gpr_slice value);
+void grpc_credentials_md_store_add_cstrings(grpc_credentials_md_store *store,
+ const char *key, const char *value);
+grpc_credentials_md_store *grpc_credentials_md_store_ref(
+ grpc_credentials_md_store *store);
+void grpc_credentials_md_store_unref(grpc_credentials_md_store *store);
+
+
/* --- grpc_credentials. --- */
/* It is the caller's responsibility to gpr_free the result if not NULL. */
char *grpc_get_well_known_google_credentials_file_path(void);
typedef void (*grpc_credentials_metadata_cb)(void *user_data,
- grpc_mdelem **md_elems,
+ grpc_credentials_md *md_elems,
size_t num_md,
grpc_credentials_status status);
@@ -96,7 +123,6 @@ typedef struct {
void (*destroy)(grpc_credentials *c);
int (*has_request_metadata)(const grpc_credentials *c);
int (*has_request_metadata_only)(const grpc_credentials *c);
- grpc_mdctx *(*get_metadata_context)(grpc_credentials *c);
void (*get_request_metadata)(grpc_credentials *c,
const char *service_url,
grpc_credentials_metadata_cb cb,
@@ -123,11 +149,6 @@ void grpc_credentials_get_request_metadata(grpc_credentials *creds,
grpc_credentials_metadata_cb cb,
void *user_data);
-/* Gets the mdctx from the credentials and increase the refcount if it exists,
- otherwise, create a new one. */
-grpc_mdctx *grpc_credentials_get_or_create_metadata_context(
- grpc_credentials *creds);
-
/* Creates a security connector for the channel. May also create new channel
args for the channel to be used in place of the passed in const args if
returned non NULL. In that case the caller is responsible for destroying
@@ -155,9 +176,9 @@ grpc_credentials *grpc_credentials_contains_type(
/* Exposed for testing only. */
grpc_credentials_status
- grpc_oauth2_token_fetcher_credentials_parse_server_response(
- const struct grpc_httpcli_response *response, grpc_mdctx *ctx,
- grpc_mdelem **token_elem, gpr_timespec *token_lifetime);
+grpc_oauth2_token_fetcher_credentials_parse_server_response(
+ const struct grpc_httpcli_response *response, grpc_credentials_md_store **token_md,
+ gpr_timespec *token_lifetime);
/* Simulates an oauth2 token fetch with the specified value for testing. */
grpc_credentials *grpc_fake_oauth2_credentials_create(
diff --git a/src/core/security/credentials_metadata.c b/src/core/security/credentials_metadata.c
new file mode 100644
index 0000000000..22c786be56
--- /dev/null
+++ b/src/core/security/credentials_metadata.c
@@ -0,0 +1,101 @@
+/*
+ *
+ * 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.
+ *
+ */
+
+#include "src/core/security/credentials.h"
+
+#include <grpc/support/alloc.h>
+
+#include <string.h>
+
+static void store_ensure_capacity(grpc_credentials_md_store *store) {
+ if (store->num_entries == store->allocated) {
+ store->allocated = (store->allocated == 0) ? 1 : store->allocated * 2;
+ store->entries = gpr_realloc(
+ store->entries, store->allocated * sizeof(grpc_credentials_md));
+ }
+}
+
+grpc_credentials_md_store *grpc_credentials_md_store_create(
+ size_t initial_capacity) {
+ grpc_credentials_md_store *store = gpr_malloc(sizeof(grpc_credentials_md_store));
+ memset(store, 0, sizeof(grpc_credentials_md_store));
+ if (initial_capacity > 0) {
+ store->entries = gpr_malloc(initial_capacity * sizeof(grpc_credentials_md));
+ store->allocated = initial_capacity;
+ }
+ gpr_ref_init(&store->refcount, 1);
+ return store;
+}
+
+void grpc_credentials_md_store_add(grpc_credentials_md_store *store,
+ gpr_slice key, gpr_slice value) {
+ if (store == NULL) return;
+ store_ensure_capacity(store);
+ store->entries[store->num_entries].key = gpr_slice_ref(key);
+ store->entries[store->num_entries].value = gpr_slice_ref(value);
+ store->num_entries++;
+}
+
+void grpc_credentials_md_store_add_cstrings(grpc_credentials_md_store *store,
+ const char *key,
+ const char *value) {
+ if (store == NULL) return;
+ store_ensure_capacity(store);
+ store->entries[store->num_entries].key = gpr_slice_from_copied_string(key);
+ store->entries[store->num_entries].value =
+ gpr_slice_from_copied_string(value);
+ store->num_entries++;
+}
+
+grpc_credentials_md_store *grpc_credentials_md_store_ref(
+ grpc_credentials_md_store *store) {
+ if (store == NULL) return NULL;
+ gpr_ref(&store->refcount);
+ return store;
+}
+
+void grpc_credentials_md_store_unref(grpc_credentials_md_store *store) {
+ if (store == NULL) return;
+ if (gpr_unref(&store->refcount)) {
+ if (store->entries != NULL) {
+ size_t i;
+ for (i = 0; i < store->num_entries; i++) {
+ gpr_slice_unref(store->entries[i].key);
+ gpr_slice_unref(store->entries[i].value);
+ }
+ gpr_free(store->entries);
+ }
+ gpr_free(store);
+ }
+}
+
diff --git a/src/core/security/security_connector.c b/src/core/security/security_connector.c
index b17e0e0dfa..11505f8cb0 100644
--- a/src/core/security/security_connector.c
+++ b/src/core/security/security_connector.c
@@ -37,6 +37,7 @@
#include "src/core/security/credentials.h"
#include "src/core/security/secure_endpoint.h"
+#include "src/core/security/security_context.h"
#include "src/core/support/env.h"
#include "src/core/support/file.h"
#include "src/core/support/string.h"
@@ -194,10 +195,14 @@ typedef struct {
static void fake_channel_destroy(grpc_security_connector *sc) {
grpc_channel_security_connector *c = (grpc_channel_security_connector *)sc;
grpc_credentials_unref(c->request_metadata_creds);
+ grpc_auth_context_unref(sc->auth_context);
gpr_free(sc);
}
-static void fake_server_destroy(grpc_security_connector *sc) { gpr_free(sc); }
+static void fake_server_destroy(grpc_security_connector *sc) {
+ grpc_auth_context_unref(sc->auth_context);
+ gpr_free(sc);
+}
static grpc_security_status fake_channel_create_handshaker(
grpc_security_connector *sc, tsi_handshaker **handshaker) {
@@ -236,6 +241,12 @@ static grpc_security_status fake_check_peer(grpc_security_connector *sc,
status = GRPC_SECURITY_ERROR;
goto end;
}
+ grpc_auth_context_unref(sc->auth_context);
+ sc->auth_context = grpc_auth_context_create(NULL, 1);
+ sc->auth_context->properties[0] = grpc_auth_property_init_from_cstring(
+ GRPC_TRANSPORT_SECURITY_TYPE_PROPERTY_NAME,
+ GRPC_FAKE_TRANSPORT_SECURITY_TYPE);
+
end:
tsi_peer_destruct(&peer);
return status;
@@ -264,6 +275,7 @@ grpc_channel_security_connector *grpc_fake_channel_security_connector_create(
grpc_credentials *request_metadata_creds, int call_host_check_is_async) {
grpc_fake_channel_security_connector *c =
gpr_malloc(sizeof(grpc_fake_channel_security_connector));
+ memset(c, 0, sizeof(grpc_fake_channel_security_connector));
gpr_ref_init(&c->base.base.refcount, 1);
c->base.base.is_client_side = 1;
c->base.base.url_scheme = GRPC_FAKE_SECURITY_URL_SCHEME;
@@ -277,7 +289,9 @@ grpc_channel_security_connector *grpc_fake_channel_security_connector_create(
grpc_security_connector *grpc_fake_server_security_connector_create(void) {
grpc_security_connector *c = gpr_malloc(sizeof(grpc_security_connector));
+ memset(c, 0, sizeof(grpc_security_connector));
gpr_ref_init(&c->refcount, 1);
+ c->is_client_side = 0;
c->vtable = &fake_server_vtable;
c->url_scheme = GRPC_FAKE_SECURITY_URL_SCHEME;
return c;
@@ -308,6 +322,7 @@ static void ssl_channel_destroy(grpc_security_connector *sc) {
if (c->target_name != NULL) gpr_free(c->target_name);
if (c->overridden_target_name != NULL) gpr_free(c->overridden_target_name);
tsi_peer_destruct(&c->peer);
+ grpc_auth_context_unref(sc->auth_context);
gpr_free(sc);
}
@@ -317,6 +332,7 @@ static void ssl_server_destroy(grpc_security_connector *sc) {
if (c->handshaker_factory != NULL) {
tsi_ssl_handshaker_factory_destroy(c->handshaker_factory);
}
+ grpc_auth_context_unref(sc->auth_context);
gpr_free(sc);
}
@@ -369,7 +385,51 @@ static int ssl_host_matches_name(const tsi_peer *peer, const char *peer_name) {
return r;
}
-static grpc_security_status ssl_check_peer(const char *peer_name,
+static grpc_auth_context *tsi_ssl_peer_to_auth_context(const tsi_peer *peer) {
+ /* We bet that iterating over a handful of properties twice will be faster
+ than having to realloc on average . */
+ size_t auth_prop_count = 1; /* for transport_security_type. */
+ size_t i;
+ const char *peer_identity_property_name = NULL;
+ grpc_auth_context *ctx = NULL;
+ for (i = 0; i < peer->property_count; i++) {
+ const tsi_peer_property *prop = &peer->properties[i];
+ if (prop->name == NULL) continue;
+ if (strcmp(prop->name, TSI_X509_SUBJECT_COMMON_NAME_PEER_PROPERTY) == 0) {
+ auth_prop_count++;
+ /* If there is no subject alt name, have the CN as the identity. */
+ if (peer_identity_property_name == NULL) {
+ peer_identity_property_name = prop->name;
+ }
+ } else if (strcmp(prop->name,
+ TSI_X509_SUBJECT_ALTERNATIVE_NAME_PEER_PROPERTY) == 0) {
+ auth_prop_count++;
+ peer_identity_property_name = prop->name;
+ }
+ }
+ ctx = grpc_auth_context_create(NULL, auth_prop_count);
+ ctx->properties[0] = grpc_auth_property_init_from_cstring(
+ GRPC_TRANSPORT_SECURITY_TYPE_PROPERTY_NAME,
+ GRPC_SSL_TRANSPORT_SECURITY_TYPE);
+ ctx->property_count = 1;
+ for (i = 0; i < peer->property_count; i++) {
+ const tsi_peer_property *prop = &peer->properties[i];
+ if (prop->name == NULL) continue;
+ if (strcmp(prop->name, TSI_X509_SUBJECT_COMMON_NAME_PEER_PROPERTY) == 0) {
+ ctx->properties[ctx->property_count++] = grpc_auth_property_init(
+ GRPC_X509_CN_PROPERTY_NAME, prop->value.data, prop->value.length);
+ } else if (strcmp(prop->name,
+ TSI_X509_SUBJECT_ALTERNATIVE_NAME_PEER_PROPERTY) == 0) {
+ ctx->properties[ctx->property_count++] = grpc_auth_property_init(
+ GRPC_X509_SAN_PROPERTY_NAME, prop->value.data, prop->value.length);
+ }
+ }
+ GPR_ASSERT(auth_prop_count == ctx->property_count);
+ return ctx;
+}
+
+static grpc_security_status ssl_check_peer(grpc_security_connector *sc,
+ const char *peer_name,
const tsi_peer *peer) {
/* Check the ALPN. */
const tsi_peer_property *p =
@@ -388,7 +448,7 @@ static grpc_security_status ssl_check_peer(const char *peer_name,
gpr_log(GPR_ERROR, "Peer name %s is not in peer certificate", peer_name);
return GRPC_SECURITY_ERROR;
}
-
+ sc->auth_context = tsi_ssl_peer_to_auth_context(peer);
return GRPC_SECURITY_OK;
}
@@ -401,9 +461,9 @@ static grpc_security_status ssl_channel_check_peer(grpc_security_connector *sc,
grpc_security_status status;
tsi_peer_destruct(&c->peer);
c->peer = peer;
- status = ssl_check_peer(c->overridden_target_name != NULL
- ? c->overridden_target_name
- : c->target_name,
+ status = ssl_check_peer(sc, c->overridden_target_name != NULL
+ ? c->overridden_target_name
+ : c->target_name,
&peer);
return status;
}
@@ -412,8 +472,7 @@ static grpc_security_status ssl_server_check_peer(grpc_security_connector *sc,
tsi_peer peer,
grpc_security_check_cb cb,
void *user_data) {
- /* TODO(jboeuf): Find a way to expose the peer to the authorization layer. */
- grpc_security_status status = ssl_check_peer(NULL, &peer);
+ grpc_security_status status = ssl_check_peer(sc, NULL, &peer);
tsi_peer_destruct(&peer);
return status;
}
diff --git a/src/core/security/security_connector.h b/src/core/security/security_connector.h
index 87b7ca9b8b..0617041448 100644
--- a/src/core/security/security_connector.h
+++ b/src/core/security/security_connector.h
@@ -77,6 +77,7 @@ struct grpc_security_connector {
gpr_refcount refcount;
int is_client_side;
const char *url_scheme;
+ grpc_auth_context *auth_context; /* Populated after the peer is checked. */
};
/* Increments the refcount. */
diff --git a/src/core/security/security_context.c b/src/core/security/security_context.c
index b90dc5097a..14c194c8f6 100644
--- a/src/core/security/security_context.c
+++ b/src/core/security/security_context.c
@@ -35,11 +35,14 @@
#include "src/core/security/security_context.h"
#include "src/core/surface/call.h"
+#include "src/core/support/string.h"
#include <grpc/grpc_security.h>
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
+/* --- grpc_call --- */
+
grpc_call_error grpc_call_set_credentials(grpc_call *call,
grpc_credentials *creds) {
grpc_client_security_context *ctx = NULL;
@@ -65,6 +68,16 @@ grpc_call_error grpc_call_set_credentials(grpc_call *call,
return GRPC_CALL_OK;
}
+const grpc_auth_context *grpc_call_auth_context(grpc_call *call) {
+ void *sec_ctx = grpc_call_context_get(call, GRPC_CONTEXT_SECURITY);
+ if (sec_ctx == NULL) return NULL;
+ return grpc_call_is_client(call)
+ ? ((grpc_client_security_context *)sec_ctx)->auth_context
+ : ((grpc_server_security_context *)sec_ctx)->auth_context;
+}
+
+/* --- grpc_client_security_context --- */
+
grpc_client_security_context *grpc_client_security_context_create(void) {
grpc_client_security_context *ctx =
gpr_malloc(sizeof(grpc_client_security_context));
@@ -75,5 +88,142 @@ grpc_client_security_context *grpc_client_security_context_create(void) {
void grpc_client_security_context_destroy(void *ctx) {
grpc_client_security_context *c = (grpc_client_security_context *)ctx;
grpc_credentials_unref(c->creds);
+ grpc_auth_context_unref(c->auth_context);
+ gpr_free(ctx);
+}
+
+/* --- grpc_server_security_context --- */
+
+grpc_server_security_context *grpc_server_security_context_create(void) {
+ grpc_server_security_context *ctx =
+ gpr_malloc(sizeof(grpc_server_security_context));
+ memset(ctx, 0, sizeof(grpc_server_security_context));
+ return ctx;
+}
+
+void grpc_server_security_context_destroy(void *ctx) {
+ grpc_server_security_context *c = (grpc_server_security_context *)ctx;
+ grpc_auth_context_unref(c->auth_context);
gpr_free(ctx);
}
+
+/* --- grpc_auth_context --- */
+
+static grpc_auth_property_iterator empty_iterator = {NULL, 0, NULL};
+
+grpc_auth_context *grpc_auth_context_create(grpc_auth_context *chained,
+ size_t property_count) {
+ grpc_auth_context *ctx = gpr_malloc(sizeof(grpc_auth_context));
+ memset(ctx, 0, sizeof(grpc_auth_context));
+ ctx->properties = gpr_malloc(property_count * sizeof(grpc_auth_property));
+ memset(ctx->properties, 0, property_count * sizeof(grpc_auth_property));
+ ctx->property_count = property_count;
+ gpr_ref_init(&ctx->refcount, 1);
+ if (chained != NULL) ctx->chained = grpc_auth_context_ref(chained);
+ return ctx;
+}
+
+grpc_auth_context *grpc_auth_context_ref(grpc_auth_context *ctx) {
+ if (ctx == NULL) return NULL;
+ gpr_ref(&ctx->refcount);
+ return ctx;
+}
+
+void grpc_auth_context_unref(grpc_auth_context *ctx) {
+ if (ctx == NULL) return;
+ if (gpr_unref(&ctx->refcount)) {
+ size_t i;
+ grpc_auth_context_unref(ctx->chained);
+ if (ctx->properties != NULL) {
+ for (i = 0; i < ctx->property_count; i++) {
+ grpc_auth_property_reset(&ctx->properties[i]);
+ }
+ gpr_free(ctx->properties);
+ }
+ gpr_free(ctx);
+ }
+}
+
+const char *grpc_auth_context_peer_identity_property_name(
+ const grpc_auth_context *ctx) {
+ return ctx->peer_identity_property_name;
+}
+
+int grpc_auth_context_peer_is_authenticated(
+ const grpc_auth_context *ctx) {
+ return ctx->peer_identity_property_name == NULL ? 0 : 1;
+}
+
+grpc_auth_property_iterator grpc_auth_context_property_iterator(
+ const grpc_auth_context *ctx) {
+ grpc_auth_property_iterator it = empty_iterator;
+ if (ctx == NULL) return it;
+ it.ctx = ctx;
+ return it;
+}
+
+const grpc_auth_property *grpc_auth_property_iterator_next(
+ grpc_auth_property_iterator *it) {
+ if (it == NULL || it->ctx == NULL) return NULL;
+ while (it->index == it->ctx->property_count) {
+ if (it->ctx->chained == NULL) return NULL;
+ it->ctx = it->ctx->chained;
+ it->index = 0;
+ }
+ if (it->name == NULL) {
+ return &it->ctx->properties[it->index++];
+ } else {
+ while (it->index < it->ctx->property_count) {
+ const grpc_auth_property *prop = &it->ctx->properties[it->index++];
+ GPR_ASSERT(prop->name != NULL);
+ if (strcmp(it->name, prop->name) == 0) {
+ return prop;
+ }
+ }
+ /* We could not find the name, try another round. */
+ return grpc_auth_property_iterator_next(it);
+ }
+}
+
+grpc_auth_property_iterator grpc_auth_context_find_properties_by_name(
+ const grpc_auth_context *ctx, const char *name) {
+ grpc_auth_property_iterator it = empty_iterator;
+ if (ctx == NULL || name == NULL) return empty_iterator;
+ it.ctx = ctx;
+ it.name = name;
+ return it;
+}
+
+grpc_auth_property_iterator grpc_auth_context_peer_identity(
+ const grpc_auth_context *ctx) {
+ if (ctx == NULL) return empty_iterator;
+ return grpc_auth_context_find_properties_by_name(
+ ctx, ctx->peer_identity_property_name);
+}
+
+grpc_auth_property grpc_auth_property_init_from_cstring(const char *name,
+ const char *value) {
+ grpc_auth_property prop;
+ prop.name = gpr_strdup(name);
+ prop.value = gpr_strdup(value);
+ prop.value_length = strlen(value);
+ return prop;
+}
+
+grpc_auth_property grpc_auth_property_init(const char *name, const char *value,
+ size_t value_length) {
+ grpc_auth_property prop;
+ prop.name = gpr_strdup(name);
+ prop.value = gpr_malloc(value_length + 1);
+ memcpy(prop.value, value, value_length);
+ prop.value[value_length] = '\0';
+ prop.value_length = value_length;
+ return prop;
+}
+
+void grpc_auth_property_reset(grpc_auth_property *property) {
+ if (property->name != NULL) gpr_free(property->name);
+ if (property->value != NULL) gpr_free(property->value);
+ memset(property, 0, sizeof(grpc_auth_property));
+}
+
diff --git a/src/core/security/security_context.h b/src/core/security/security_context.h
index 561633b452..d8909cd6f1 100644
--- a/src/core/security/security_context.h
+++ b/src/core/security/security_context.h
@@ -36,13 +36,59 @@
#include "src/core/security/credentials.h"
-/* Security context attached to a client-side call. */
+/* --- grpc_auth_context ---
+
+ High level authentication context object. Can optionally be chained. */
+
+/* Property names are always NULL terminated. */
+
+struct grpc_auth_context {
+ struct grpc_auth_context *chained;
+ grpc_auth_property *properties;
+ size_t property_count;
+ gpr_refcount refcount;
+ const char *peer_identity_property_name;
+};
+
+/* Constructor. */
+grpc_auth_context *grpc_auth_context_create(grpc_auth_context *chained,
+ size_t property_count);
+
+/* Refcounting. */
+grpc_auth_context *grpc_auth_context_ref(
+ grpc_auth_context *ctx);
+void grpc_auth_context_unref(grpc_auth_context *ctx);
+
+grpc_auth_property grpc_auth_property_init_from_cstring(const char *name,
+ const char *value);
+
+grpc_auth_property grpc_auth_property_init(const char *name, const char *value,
+ size_t value_length);
+
+void grpc_auth_property_reset(grpc_auth_property *property);
+
+/* --- grpc_client_security_context ---
+
+ Internal client-side security context. */
+
typedef struct {
grpc_credentials *creds;
+ grpc_auth_context *auth_context;
} grpc_client_security_context;
grpc_client_security_context *grpc_client_security_context_create(void);
void grpc_client_security_context_destroy(void *ctx);
+/* --- grpc_server_security_context ---
+
+ Internal server-side security context. */
+
+typedef struct {
+ grpc_auth_context *auth_context;
+} grpc_server_security_context;
+
+grpc_server_security_context *grpc_server_security_context_create(void);
+void grpc_server_security_context_destroy(void *ctx);
+
#endif /* GRPC_INTERNAL_CORE_SECURITY_SECURITY_CONTEXT_H */
diff --git a/src/core/security/server_auth_filter.c b/src/core/security/server_auth_filter.c
new file mode 100644
index 0000000000..1823f75808
--- /dev/null
+++ b/src/core/security/server_auth_filter.c
@@ -0,0 +1,128 @@
+/*
+ *
+ * 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.
+ *
+ */
+
+#include "src/core/security/auth_filters.h"
+#include "src/core/security/security_connector.h"
+#include "src/core/security/security_context.h"
+
+#include <grpc/support/log.h>
+
+typedef struct call_data {
+ int unused; /* C89 requires at least one struct element */
+} call_data;
+
+typedef struct channel_data {
+ grpc_security_connector *security_connector;
+} channel_data;
+
+/* Called either:
+ - in response to an API call (or similar) from above, to send something
+ - a network event (or similar) from below, to receive something
+ op contains type and call direction information, in addition to the data
+ that is being sent or received. */
+static void auth_start_transport_op(grpc_call_element *elem,
+ grpc_transport_op *op) {
+ /* TODO(jboeuf): Get the metadata and get a new context from it. */
+
+ /* pass control down the stack */
+ grpc_call_next_op(elem, op);
+}
+
+/* Called on special channel events, such as disconnection or new incoming
+ calls on the server */
+static void channel_op(grpc_channel_element *elem,
+ grpc_channel_element *from_elem, grpc_channel_op *op) {
+ grpc_channel_next_op(elem, op);
+}
+
+/* Constructor for call_data */
+static void init_call_elem(grpc_call_element *elem,
+ const void *server_transport_data,
+ grpc_transport_op *initial_op) {
+ /* grab pointers to our data from the call element */
+ call_data *calld = elem->call_data;
+ channel_data *chand = elem->channel_data;
+ grpc_server_security_context *server_ctx = NULL;
+
+ /* initialize members */
+ calld->unused = 0;
+
+ GPR_ASSERT(initial_op && initial_op->context != NULL &&
+ chand->security_connector->auth_context != NULL &&
+ initial_op->context[GRPC_CONTEXT_SECURITY].value == NULL);
+
+ /* Create a security context for the call and reference the auth context from
+ the channel. */
+ server_ctx = grpc_server_security_context_create();
+ server_ctx->auth_context =
+ grpc_auth_context_ref(chand->security_connector->auth_context);
+ initial_op->context[GRPC_CONTEXT_SECURITY].value = server_ctx;
+ initial_op->context[GRPC_CONTEXT_SECURITY].destroy =
+ grpc_server_security_context_destroy;
+}
+
+/* Destructor for call_data */
+static void destroy_call_elem(grpc_call_element *elem) {
+}
+
+/* Constructor for channel_data */
+static void init_channel_elem(grpc_channel_element *elem,
+ const grpc_channel_args *args, grpc_mdctx *mdctx,
+ int is_first, int is_last) {
+ grpc_security_connector *sc = grpc_find_security_connector_in_args(args);
+ /* grab pointers to our data from the channel element */
+ channel_data *chand = elem->channel_data;
+
+ /* The first and the last filters tend to be implemented differently to
+ handle the case that there's no 'next' filter to call on the up or down
+ path */
+ GPR_ASSERT(!is_first);
+ GPR_ASSERT(!is_last);
+ GPR_ASSERT(sc != NULL);
+
+ /* initialize members */
+ GPR_ASSERT(!sc->is_client_side);
+ chand->security_connector = grpc_security_connector_ref(sc);
+}
+
+/* Destructor for channel data */
+static void destroy_channel_elem(grpc_channel_element *elem) {
+ /* grab pointers to our data from the channel element */
+ channel_data *chand = elem->channel_data;
+ grpc_security_connector_unref(chand->security_connector);
+}
+
+const grpc_channel_filter grpc_server_auth_filter = {
+ auth_start_transport_op, channel_op, sizeof(call_data), init_call_elem,
+ destroy_call_elem, sizeof(channel_data), init_channel_elem,
+ destroy_channel_elem, "server-auth"};
diff --git a/src/core/security/server_secure_chttp2.c b/src/core/security/server_secure_chttp2.c
index db9d545c0e..3519930f38 100644
--- a/src/core/security/server_secure_chttp2.c
+++ b/src/core/security/server_secure_chttp2.c
@@ -35,10 +35,12 @@
#include <string.h>
+#include "src/core/channel/channel_args.h"
#include "src/core/channel/http_server_filter.h"
#include "src/core/iomgr/endpoint.h"
#include "src/core/iomgr/resolve_address.h"
#include "src/core/iomgr/tcp_server.h"
+#include "src/core/security/auth_filters.h"
#include "src/core/security/credentials.h"
#include "src/core/security/security_connector.h"
#include "src/core/security/secure_transport_setup.h"
@@ -69,13 +71,21 @@ static void state_unref(grpc_server_secure_state *state) {
}
}
-static grpc_transport_setup_result setup_transport(void *server,
+static grpc_transport_setup_result setup_transport(void *statep,
grpc_transport *transport,
grpc_mdctx *mdctx) {
static grpc_channel_filter const *extra_filters[] = {
- &grpc_http_server_filter};
- return grpc_server_setup_transport(server, transport, extra_filters,
- GPR_ARRAY_SIZE(extra_filters), mdctx);
+ &grpc_server_auth_filter, &grpc_http_server_filter};
+ grpc_server_secure_state *state = statep;
+ grpc_transport_setup_result result;
+ grpc_arg connector_arg = grpc_security_connector_to_arg(state->sc);
+ grpc_channel_args *args_copy = grpc_channel_args_copy_and_add(
+ grpc_server_get_channel_args(state->server), &connector_arg);
+ result = grpc_server_setup_transport(state->server, transport, extra_filters,
+ GPR_ARRAY_SIZE(extra_filters), mdctx,
+ args_copy);
+ grpc_channel_args_destroy(args_copy);
+ return result;
}
static void on_secure_transport_setup_done(void *statep,
@@ -85,10 +95,9 @@ static void on_secure_transport_setup_done(void *statep,
if (status == GRPC_SECURITY_OK) {
gpr_mu_lock(&state->mu);
if (!state->is_shutdown) {
- grpc_create_chttp2_transport(setup_transport, state->server,
- grpc_server_get_channel_args(state->server),
- secure_endpoint, NULL, 0,
- grpc_mdctx_create(), 0);
+ grpc_create_chttp2_transport(
+ setup_transport, state, grpc_server_get_channel_args(state->server),
+ secure_endpoint, NULL, 0, grpc_mdctx_create(), 0);
} else {
/* We need to consume this here, because the server may already have gone
* away. */
diff --git a/src/core/support/cmdline.c b/src/core/support/cmdline.c
index 72f46c1bd7..530952c437 100644
--- a/src/core/support/cmdline.c
+++ b/src/core/support/cmdline.c
@@ -131,33 +131,63 @@ void gpr_cmdline_on_extra_arg(
cl->extra_arg_help = help;
}
-static void print_usage_and_die(gpr_cmdline *cl) {
+/* recursively descend argument list, adding the last element
+ to s first - so that arguments are added in the order they were
+ added to the list by api calls */
+static void add_args_to_usage(gpr_strvec *s, arg *a) {
+ char *tmp;
+
+ if (!a) return;
+ add_args_to_usage(s, a->next);
+
+ switch (a->type) {
+ case ARGTYPE_BOOL:
+ gpr_asprintf(&tmp, " [--%s|--no-%s]", a->name, a->name);
+ gpr_strvec_add(s, tmp);
+ break;
+ case ARGTYPE_STRING:
+ gpr_asprintf(&tmp, " [--%s=string]", a->name);
+ gpr_strvec_add(s, tmp);
+ break;
+ case ARGTYPE_INT:
+ gpr_asprintf(&tmp, " [--%s=int]", a->name);
+ gpr_strvec_add(s, tmp);
+ break;
+ }
+}
+
+char *gpr_cmdline_usage_string(gpr_cmdline *cl, const char *argv0) {
/* TODO(ctiller): make this prettier */
- arg *a;
- const char *name = strrchr(cl->argv0, '/');
+ gpr_strvec s;
+ char *tmp;
+ const char *name = strrchr(argv0, '/');
+
if (name) {
name++;
} else {
- name = cl->argv0;
- }
- fprintf(stderr, "Usage: %s", name);
- for (a = cl->args; a; a = a->next) {
- switch (a->type) {
- case ARGTYPE_BOOL:
- fprintf(stderr, " [--%s|--no-%s]", a->name, a->name);
- break;
- case ARGTYPE_STRING:
- fprintf(stderr, " [--%s=string]", a->name);
- break;
- case ARGTYPE_INT:
- fprintf(stderr, " [--%s=int]", a->name);
- break;
- }
+ name = argv0;
}
+
+ gpr_strvec_init(&s);
+
+ gpr_asprintf(&tmp, "Usage: %s", name);
+ gpr_strvec_add(&s, tmp);
+ add_args_to_usage(&s, cl->args);
if (cl->extra_arg) {
- fprintf(stderr, " [%s...]", cl->extra_arg_name);
+ gpr_asprintf(&tmp, " [%s...]", cl->extra_arg_name);
+ gpr_strvec_add(&s, tmp);
}
- fprintf(stderr, "\n");
+ gpr_strvec_add(&s, gpr_strdup("\n"));
+
+ tmp = gpr_strvec_flatten(&s, NULL);
+ gpr_strvec_destroy(&s);
+ return tmp;
+}
+
+static void print_usage_and_die(gpr_cmdline *cl) {
+ char *usage = gpr_cmdline_usage_string(cl, cl->argv0);
+ fprintf(stderr, "%s", usage);
+ gpr_free(usage);
exit(1);
}
diff --git a/src/core/surface/call.c b/src/core/surface/call.c
index 4d2ba7cd7d..e3995a407b 100644
--- a/src/core/surface/call.c
+++ b/src/core/surface/call.c
@@ -205,8 +205,8 @@ struct grpc_call {
/* Received call statuses from various sources */
received_status status[STATUS_SOURCE_COUNT];
- void *context[GRPC_CONTEXT_COUNT];
- void (*destroy_context[GRPC_CONTEXT_COUNT])(void *);
+ /* Contexts for various subsystems (security, tracing, ...). */
+ grpc_call_context_element context[GRPC_CONTEXT_COUNT];
/* Deadline alarm - if have_alarm is non-zero */
grpc_alarm alarm;
@@ -344,8 +344,8 @@ static void destroy_call(void *call, int ignored_success) {
grpc_mdelem_unref(c->send_initial_metadata[i].md);
}
for (i = 0; i < GRPC_CONTEXT_COUNT; i++) {
- if (c->destroy_context[i]) {
- c->destroy_context[i](c->context[i]);
+ if (c->context[i].destroy) {
+ c->context[i].destroy(c->context[i].value);
}
}
grpc_sopb_destroy(&c->send_ops);
@@ -1300,15 +1300,15 @@ grpc_call_error grpc_call_start_batch(grpc_call *call, const grpc_op *ops,
void grpc_call_context_set(grpc_call *call, grpc_context_index elem, void *value,
void (*destroy)(void *value)) {
- if (call->destroy_context[elem]) {
- call->destroy_context[elem](value);
+ if (call->context[elem].destroy) {
+ call->context[elem].destroy(call->context[elem].value);
}
- call->context[elem] = value;
- call->destroy_context[elem] = destroy;
+ call->context[elem].value = value;
+ call->context[elem].destroy = destroy;
}
void *grpc_call_context_get(grpc_call *call, grpc_context_index elem) {
- return call->context[elem];
+ return call->context[elem].value;
}
gpr_uint8 grpc_call_is_client(grpc_call *call) { return call->is_client; }
diff --git a/src/core/surface/secure_channel_create.c b/src/core/surface/secure_channel_create.c
index 3e331293b5..a71d12291e 100644
--- a/src/core/surface/secure_channel_create.c
+++ b/src/core/surface/secure_channel_create.c
@@ -46,7 +46,7 @@
#include "src/core/channel/http_client_filter.h"
#include "src/core/iomgr/resolve_address.h"
#include "src/core/iomgr/tcp_client.h"
-#include "src/core/security/auth.h"
+#include "src/core/security/auth_filters.h"
#include "src/core/security/credentials.h"
#include "src/core/security/secure_transport_setup.h"
#include "src/core/support/string.h"
@@ -226,7 +226,7 @@ grpc_channel *grpc_secure_channel_create(grpc_credentials *creds,
GRPC_SECURITY_OK) {
return grpc_lame_client_channel_create();
}
- mdctx = grpc_credentials_get_or_create_metadata_context(creds);
+ mdctx = grpc_mdctx_create();
s = gpr_malloc(sizeof(setup));
connector_arg = grpc_security_connector_to_arg(&connector->base);
diff --git a/src/core/surface/server.c b/src/core/surface/server.c
index a60d5f7717..60606c75e4 100644
--- a/src/core/surface/server.c
+++ b/src/core/surface/server.c
@@ -701,7 +701,7 @@ void grpc_server_start(grpc_server *server) {
grpc_transport_setup_result grpc_server_setup_transport(
grpc_server *s, grpc_transport *transport,
grpc_channel_filter const **extra_filters, size_t num_extra_filters,
- grpc_mdctx *mdctx) {
+ grpc_mdctx *mdctx, const grpc_channel_args *args) {
size_t num_filters = s->channel_filter_count + num_extra_filters + 1;
grpc_channel_filter const **filters =
gpr_malloc(sizeof(grpc_channel_filter *) * num_filters);
@@ -732,8 +732,8 @@ grpc_transport_setup_result grpc_server_setup_transport(
grpc_transport_add_to_pollset(transport, grpc_cq_pollset(s->cqs[i]));
}
- channel = grpc_channel_create_from_filters(filters, num_filters,
- s->channel_args, mdctx, 0);
+ channel =
+ grpc_channel_create_from_filters(filters, num_filters, args, mdctx, 0);
chand = (channel_data *)grpc_channel_stack_element(
grpc_channel_get_channel_stack(channel), 0)
->channel_data;
diff --git a/src/core/surface/server.h b/src/core/surface/server.h
index 58f17272a4..91a1a2a7f6 100644
--- a/src/core/surface/server.h
+++ b/src/core/surface/server.h
@@ -58,7 +58,7 @@ void grpc_server_listener_destroy_done(void *server);
grpc_transport_setup_result grpc_server_setup_transport(
grpc_server *server, grpc_transport *transport,
grpc_channel_filter const **extra_filters, size_t num_extra_filters,
- grpc_mdctx *mdctx);
+ grpc_mdctx *mdctx, const grpc_channel_args *args);
const grpc_channel_args *grpc_server_get_channel_args(grpc_server *server);
diff --git a/src/core/surface/server_chttp2.c b/src/core/surface/server_chttp2.c
index 7b5c2f227b..7e49a531df 100644
--- a/src/core/surface/server_chttp2.c
+++ b/src/core/surface/server_chttp2.c
@@ -48,7 +48,8 @@ static grpc_transport_setup_result setup_transport(void *server,
static grpc_channel_filter const *extra_filters[] = {
&grpc_http_server_filter};
return grpc_server_setup_transport(server, transport, extra_filters,
- GPR_ARRAY_SIZE(extra_filters), mdctx);
+ GPR_ARRAY_SIZE(extra_filters), mdctx,
+ grpc_server_get_channel_args(server));
}
static void new_transport(void *server, grpc_endpoint *tcp) {
diff --git a/src/core/transport/metadata.h b/src/core/transport/metadata.h
index e7508718f5..76e3f3c1f8 100644
--- a/src/core/transport/metadata.h
+++ b/src/core/transport/metadata.h
@@ -96,6 +96,7 @@ size_t grpc_mdctx_get_mdtab_free_test_only(grpc_mdctx *mdctx);
/* Constructors for grpc_mdstr instances; take a variety of data types that
clients may have handy */
grpc_mdstr *grpc_mdstr_from_string(grpc_mdctx *ctx, const char *str);
+/* Unrefs the slice. */
grpc_mdstr *grpc_mdstr_from_slice(grpc_mdctx *ctx, gpr_slice slice);
grpc_mdstr *grpc_mdstr_from_buffer(grpc_mdctx *ctx, const gpr_uint8 *str,
size_t length);
@@ -110,6 +111,7 @@ grpc_mdelem *grpc_mdelem_from_metadata_strings(grpc_mdctx *ctx, grpc_mdstr *key,
grpc_mdstr *value);
grpc_mdelem *grpc_mdelem_from_strings(grpc_mdctx *ctx, const char *key,
const char *value);
+/* Unrefs the slices. */
grpc_mdelem *grpc_mdelem_from_slices(grpc_mdctx *ctx, gpr_slice key,
gpr_slice value);
grpc_mdelem *grpc_mdelem_from_string_and_buffer(grpc_mdctx *ctx,
diff --git a/src/core/transport/transport.h b/src/core/transport/transport.h
index 7a389ea393..6f8d39e352 100644
--- a/src/core/transport/transport.h
+++ b/src/core/transport/transport.h
@@ -38,6 +38,7 @@
#include "src/core/iomgr/pollset.h"
#include "src/core/transport/stream_op.h"
+#include "src/core/channel/context.h"
/* forward declarations */
typedef struct grpc_transport grpc_transport;
@@ -78,7 +79,7 @@ typedef struct grpc_transport_op {
grpc_mdstr *cancel_message;
/* Indexes correspond to grpc_context_index enum values */
- void *const *context;
+ grpc_call_context_element *context;
} grpc_transport_op;
/* Callbacks made from the transport to the upper layers of grpc. */
diff --git a/src/cpp/server/server.cc b/src/cpp/server/server.cc
index e66b4ed2d8..80eb488b41 100644
--- a/src/cpp/server/server.cc
+++ b/src/cpp/server/server.cc
@@ -67,6 +67,10 @@ class Server::SyncRequest GRPC_FINAL : public CompletionQueueTag {
grpc_metadata_array_init(&request_metadata_);
}
+ ~SyncRequest() {
+ grpc_metadata_array_destroy(&request_metadata_);
+ }
+
static SyncRequest* Wait(CompletionQueue* cq, bool* ok) {
void* tag = nullptr;
*ok = false;
diff --git a/src/csharp/Grpc.Auth/Grpc.Auth.nuspec b/src/csharp/Grpc.Auth/Grpc.Auth.nuspec
index 85aee35566..171259d18d 100644
--- a/src/csharp/Grpc.Auth/Grpc.Auth.nuspec
+++ b/src/csharp/Grpc.Auth/Grpc.Auth.nuspec
@@ -7,7 +7,7 @@
<description>Auth library for C# implementation of gRPC - an RPC library and framework. See project site for more info.</description>
<version>0.5.0</version>
<authors>Google Inc.</authors>
- <owners>jtattermusch</owners>
+ <owners>grpc-packages</owners>
<licenseUrl>https://github.com/grpc/grpc/blob/master/LICENSE</licenseUrl>
<projectUrl>https://github.com/grpc/grpc</projectUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
diff --git a/src/csharp/Grpc.Core/Grpc.Core.nuspec b/src/csharp/Grpc.Core/Grpc.Core.nuspec
index 69e8497bb7..42eb90c9a3 100644
--- a/src/csharp/Grpc.Core/Grpc.Core.nuspec
+++ b/src/csharp/Grpc.Core/Grpc.Core.nuspec
@@ -7,7 +7,7 @@
<description>Core C# implementation of gRPC - an RPC library and framework. See project site for more info.</description>
<version>0.5.0</version>
<authors>Google Inc.</authors>
- <owners>jtattermusch</owners>
+ <owners>grpc-packages</owners>
<licenseUrl>https://github.com/grpc/grpc/blob/master/LICENSE</licenseUrl>
<projectUrl>https://github.com/grpc/grpc</projectUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
diff --git a/src/csharp/Grpc.Tools.nuspec b/src/csharp/Grpc.Tools.nuspec
new file mode 100644
index 0000000000..155c2ef8c4
--- /dev/null
+++ b/src/csharp/Grpc.Tools.nuspec
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<package>
+ <metadata>
+ <id>Grpc.Tools</id>
+ <title>gRPC C# Tools</title>
+ <summary>Tools for C# implementation of gRPC - an RPC library and framework</summary>
+ <description>Precompiled Windows binaries for generating protocol buffer messages and gRPC client/server code</description>
+ <version>0.5.0</version>
+ <authors>Google Inc.</authors>
+ <owners>grpc-packages</owners>
+ <licenseUrl>https://github.com/grpc/grpc/blob/master/LICENSE</licenseUrl>
+ <projectUrl>https://github.com/grpc/grpc</projectUrl>
+ <requireLicenseAcceptance>false</requireLicenseAcceptance>
+ <releaseNotes>protoc.exe - protocol buffer compiler v3.0.0-alpha-3; grpc_csharp_plugin.exe - gRPC C# protoc plugin version 0.5.0</releaseNotes>
+ <copyright>Copyright 2015, Google Inc.</copyright>
+ <tags>gRPC RPC Protocol HTTP/2</tags>
+ </metadata>
+ <files>
+ <file src="protoc.exe" target="tools" />
+ <file src="grpc_csharp_plugin.exe" target="tools" />
+ </files>
+</package>
diff --git a/src/csharp/Grpc.nuspec b/src/csharp/Grpc.nuspec
index e3195e1806..263e016339 100644
--- a/src/csharp/Grpc.nuspec
+++ b/src/csharp/Grpc.nuspec
@@ -5,9 +5,9 @@
<title>gRPC C#</title>
<summary>C# implementation of gRPC - an RPC library and framework</summary>
<description>C# implementation of gRPC - an RPC library and framework. See project site for more info.</description>
- <version>0.5.0</version>
+ <version>0.5.0.1</version>
<authors>Google Inc.</authors>
- <owners>jtattermusch</owners>
+ <owners>grpc-packages</owners>
<licenseUrl>https://github.com/grpc/grpc/blob/master/LICENSE</licenseUrl>
<projectUrl>https://github.com/grpc/grpc</projectUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
diff --git a/src/csharp/README.md b/src/csharp/README.md
index 43d519349f..bb5e165986 100644
--- a/src/csharp/README.md
+++ b/src/csharp/README.md
@@ -35,15 +35,16 @@ Usage: Linux (Mono)
- (preferred approach) add `libgrpc_csharp_ext.so` to `/etc/ld.so.cache` by running:
```sh
- echo "$HOME/.linuxbrew/lib" | sudo tee /etc/ld.so.conf.d/zzz_brew_lib.conf
- sudo ldconfig
+ $ echo "$HOME/.linuxbrew/lib" | sudo tee /etc/ld.so.conf.d/zzz_brew_lib.conf
+ $ sudo ldconfig
```
- (adhoc approach) set `LD_LIBRARY_PATH` environment variable to point to directory containing `libgrpc_csharp_ext.so`:
```sh
- export LD_LIBRARY_PATH=$HOME/.linuxbrew/lib:${LD_LIBRARY_PATH}
+ $ export LD_LIBRARY_PATH=$HOME/.linuxbrew/lib:${LD_LIBRARY_PATH}
```
+ - (if you are contributor) installing gRPC from sources using `sudo make install_grpc_csharp_ext` also works.
- Open MonoDevelop and start a new project/solution.
@@ -87,14 +88,14 @@ If you are a user of gRPC C#, go to Usage section above.
a convenience batch script that builds everything for you.
```
- buildall.bat
+ > buildall.bat
```
- Open Grpc.sln using Visual Studio 2013. NuGet dependencies will be restored
upon build (you need to have NuGet add-in installed).
-Building: Linux & Mono
+Building: Linux (Mono)
----------------------
You only need to go through these steps if you are planning to develop gRPC C#.
@@ -103,8 +104,8 @@ If you are a user of gRPC C#, go to Usage section above.
- Prerequisites for development: Mono 3.2.8+, MonoDevelop 5.9 with NuGet and NUnit add-ins installed.
```sh
- sudo apt-get install mono-devel
- sudo apt-get install nunit nunit-console
+ $ sudo apt-get install mono-devel
+ $ sudo apt-get install nunit nunit-console
```
You can use older versions of MonoDevelop, but then you might need to restore
@@ -114,8 +115,8 @@ don't support NuGet add-in.
- Compile and install the gRPC C# extension library (that will be used via
P/Invoke from C#).
```sh
- make grpc_csharp_ext
- sudo make install_grpc_csharp_ext
+ $ make grpc_csharp_ext
+ $ sudo make install_grpc_csharp_ext
```
- Use MonoDevelop to open the solution Grpc.sln
@@ -135,9 +136,9 @@ Then you should be able to run all the test from the Test View.
After building the solution, you can also run the tests from command line
using nunit-console tool.
-```
+```sh
# from Grpc.Core.Test/bin/Debug directory
-nunit-console Grpc.Core.Tests.dll
+$ nunit-console Grpc.Core.Tests.dll
```
Contents
diff --git a/src/csharp/build_packages.bat b/src/csharp/build_packages.bat
index 7cb78bddf4..3412129fb2 100644
--- a/src/csharp/build_packages.bat
+++ b/src/csharp/build_packages.bat
@@ -13,6 +13,7 @@ endlocal
%NUGET% pack ..\..\vsprojects\nuget_package\grpc.native.csharp_ext.nuspec || goto :error
%NUGET% pack Grpc.Core\Grpc.Core.nuspec -Symbols || goto :error
%NUGET% pack Grpc.Auth\Grpc.Auth.nuspec -Symbols || goto :error
+%NUGET% pack Grpc.Tools.nuspec || goto :error
%NUGET% pack Grpc.nuspec || goto :error
goto :EOF
diff --git a/src/objective-c/GRPCClient/private/GRPCSecureChannel.m b/src/objective-c/GRPCClient/private/GRPCSecureChannel.m
index 47bdfe3f28..2cbc6e0f83 100644
--- a/src/objective-c/GRPCClient/private/GRPCSecureChannel.m
+++ b/src/objective-c/GRPCClient/private/GRPCSecureChannel.m
@@ -38,13 +38,17 @@
@implementation GRPCSecureChannel
- (instancetype)initWithHost:(NSString *)host {
- // TODO(jcanizales): Load certs only once.
- NSURL *certsURL = [[NSBundle mainBundle] URLForResource:@"gRPC.bundle/roots" withExtension:@"pem"];
- NSData *certsData = [NSData dataWithContentsOfURL:certsURL];
- NSString *certsString = [[NSString alloc] initWithData:certsData encoding:NSUTF8StringEncoding];
-
- grpc_credentials *credentials = grpc_ssl_credentials_create(certsString.UTF8String, NULL);
- return (self = [super initWithChannel:grpc_secure_channel_create(credentials,
+ static const grpc_credentials *kCredentials;
+ static dispatch_once_t loading;
+ dispatch_once(&loading, ^{
+ // Do not use NSBundle.mainBundle, as it's nil for tests of library projects.
+ NSBundle *bundle = [NSBundle bundleForClass:self.class];
+ NSString *certsPath = [bundle pathForResource:@"gRPC.bundle/roots" ofType:@"pem"];
+ NSData *certsData = [NSData dataWithContentsOfFile:certsPath];
+ NSString *certsString = [[NSString alloc] initWithData:certsData encoding:NSUTF8StringEncoding];
+ kCredentials = grpc_ssl_credentials_create(certsString.UTF8String, NULL);
+ });
+ return (self = [super initWithChannel:grpc_secure_channel_create(kCredentials,
host.UTF8String,
NULL)]);
}
diff --git a/src/objective-c/README.md b/src/objective-c/README.md
index 167016cc2c..921eb69231 100644
--- a/src/objective-c/README.md
+++ b/src/objective-c/README.md
@@ -50,13 +50,15 @@ Pod::Spec.new do |s|
s.osx.deployment_target = '10.8'
s.subspec 'Messages' do |ms|
- ms.source_files = '*.pbobjc.{h,m}'
+ ms.source_files = '*.pbobjc.{h,m}', '**/*.pbobjc.{h,m}'
+ ms.header_mappings_dir = '.'
ms.requires_arc = false
ms.dependency 'Protobuf', '~> 3.0'
end
s.subspec 'Services' do |ss|
- ss.source_files = '*.pbrpc.{h,m}'
+ ss.source_files = '*.pbrpc.{h,m}', '**/*.pbrpc.{h,m}'
+ ss.header_mappings_dir = '.'
ss.requires_arc = true
ss.dependency 'gRPC', '~> 0.0'
ss.dependency '<Podspec file name>/Messages'
diff --git a/src/objective-c/examples/Sample/Podfile b/src/objective-c/examples/Sample/Podfile
index e8b78647ac..f3c49c12a1 100644
--- a/src/objective-c/examples/Sample/Podfile
+++ b/src/objective-c/examples/Sample/Podfile
@@ -3,13 +3,7 @@ platform :ios, '8.0'
pod 'gRPC', :path => "../../../.."
pod 'Protobuf', :git => 'https://github.com/google/protobuf.git'
-pod 'Route_guide', :path => "RouteGuideClient"
-pod 'RemoteTest', :path => "RemoteTestClient"
-
-link_with 'Sample', 'SampleTests'
+pod 'RemoteTest', :path => "../../generated_libraries/RemoteTestClient"
target 'Sample' do
end
-
-target 'SampleTests' do
-end
diff --git a/src/objective-c/examples/Sample/Sample.xcodeproj/project.pbxproj b/src/objective-c/examples/Sample/Sample.xcodeproj/project.pbxproj
index 17c2255b5a..611eb6032d 100644
--- a/src/objective-c/examples/Sample/Sample.xcodeproj/project.pbxproj
+++ b/src/objective-c/examples/Sample/Sample.xcodeproj/project.pbxproj
@@ -7,33 +7,16 @@
objects = {
/* Begin PBXBuildFile section */
- 60BBBBB15823BBF7639D7AA9 /* libPods.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 2DC7B7C4C0410F43B9621631 /* libPods.a */; };
- 6340F0491AE66E3300FB6A3D /* RemoteProtoTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 6340F0481AE66E3300FB6A3D /* RemoteProtoTests.m */; };
- 6356D1DE1AC11FE00075FBBC /* RemoteTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 6356D1DD1AC11FE00075FBBC /* RemoteTests.m */; };
6369A2701A9322E20015FC5C /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 6369A26F1A9322E20015FC5C /* main.m */; };
6369A2731A9322E20015FC5C /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 6369A2721A9322E20015FC5C /* AppDelegate.m */; };
6369A2761A9322E20015FC5C /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 6369A2751A9322E20015FC5C /* ViewController.m */; };
6369A2791A9322E20015FC5C /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 6369A2771A9322E20015FC5C /* Main.storyboard */; };
6369A27B1A9322E20015FC5C /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 6369A27A1A9322E20015FC5C /* Images.xcassets */; };
- 6369A27E1A9322E20015FC5C /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 6369A27C1A9322E20015FC5C /* LaunchScreen.xib */; };
- 6369A28A1A9322E20015FC5C /* SampleTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 6369A2891A9322E20015FC5C /* SampleTests.m */; };
FC81FE63CA655031F3524EC0 /* libPods.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 2DC7B7C4C0410F43B9621631 /* libPods.a */; };
/* End PBXBuildFile section */
-/* Begin PBXContainerItemProxy section */
- 6369A2841A9322E20015FC5C /* PBXContainerItemProxy */ = {
- isa = PBXContainerItemProxy;
- containerPortal = 6369A2621A9322E20015FC5C /* Project object */;
- proxyType = 1;
- remoteGlobalIDString = 6369A2691A9322E20015FC5C;
- remoteInfo = Sample;
- };
-/* End PBXContainerItemProxy section */
-
/* Begin PBXFileReference section */
2DC7B7C4C0410F43B9621631 /* libPods.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libPods.a; sourceTree = BUILT_PRODUCTS_DIR; };
- 6340F0481AE66E3300FB6A3D /* RemoteProtoTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RemoteProtoTests.m; sourceTree = "<group>"; };
- 6356D1DD1AC11FE00075FBBC /* RemoteTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RemoteTests.m; sourceTree = "<group>"; };
6369A26A1A9322E20015FC5C /* Sample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Sample.app; sourceTree = BUILT_PRODUCTS_DIR; };
6369A26E1A9322E20015FC5C /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
6369A26F1A9322E20015FC5C /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
@@ -43,10 +26,6 @@
6369A2751A9322E20015FC5C /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = "<group>"; };
6369A2781A9322E20015FC5C /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
6369A27A1A9322E20015FC5C /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = "<group>"; };
- 6369A27D1A9322E20015FC5C /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = "<group>"; };
- 6369A2831A9322E20015FC5C /* SampleTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SampleTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
- 6369A2881A9322E20015FC5C /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
- 6369A2891A9322E20015FC5C /* SampleTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SampleTests.m; sourceTree = "<group>"; };
AC29DD6FCDF962F519FEBB0D /* Pods.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.debug.xcconfig; path = "Pods/Target Support Files/Pods/Pods.debug.xcconfig"; sourceTree = "<group>"; };
C68330F8D451CC6ACEABA09F /* Pods.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.release.xcconfig; path = "Pods/Target Support Files/Pods/Pods.release.xcconfig"; sourceTree = "<group>"; };
/* End PBXFileReference section */
@@ -60,14 +39,6 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
- 6369A2801A9322E20015FC5C /* Frameworks */ = {
- isa = PBXFrameworksBuildPhase;
- buildActionMask = 2147483647;
- files = (
- 60BBBBB15823BBF7639D7AA9 /* libPods.a in Frameworks */,
- );
- runOnlyForDeploymentPostprocessing = 0;
- };
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
@@ -75,7 +46,6 @@
isa = PBXGroup;
children = (
6369A26C1A9322E20015FC5C /* Sample */,
- 6369A2861A9322E20015FC5C /* SampleTests */,
6369A26B1A9322E20015FC5C /* Products */,
AB3331C9AE6488E61B2B094E /* Pods */,
C4C2C5219053E079C9EFB930 /* Frameworks */,
@@ -86,7 +56,6 @@
isa = PBXGroup;
children = (
6369A26A1A9322E20015FC5C /* Sample.app */,
- 6369A2831A9322E20015FC5C /* SampleTests.xctest */,
);
name = Products;
sourceTree = "<group>";
@@ -100,7 +69,6 @@
6369A2751A9322E20015FC5C /* ViewController.m */,
6369A2771A9322E20015FC5C /* Main.storyboard */,
6369A27A1A9322E20015FC5C /* Images.xcassets */,
- 6369A27C1A9322E20015FC5C /* LaunchScreen.xib */,
6369A26D1A9322E20015FC5C /* Supporting Files */,
);
path = Sample;
@@ -115,25 +83,6 @@
name = "Supporting Files";
sourceTree = "<group>";
};
- 6369A2861A9322E20015FC5C /* SampleTests */ = {
- isa = PBXGroup;
- children = (
- 6340F0481AE66E3300FB6A3D /* RemoteProtoTests.m */,
- 6369A2891A9322E20015FC5C /* SampleTests.m */,
- 6369A2871A9322E20015FC5C /* Supporting Files */,
- 6356D1DD1AC11FE00075FBBC /* RemoteTests.m */,
- );
- path = SampleTests;
- sourceTree = "<group>";
- };
- 6369A2871A9322E20015FC5C /* Supporting Files */ = {
- isa = PBXGroup;
- children = (
- 6369A2881A9322E20015FC5C /* Info.plist */,
- );
- name = "Supporting Files";
- sourceTree = "<group>";
- };
AB3331C9AE6488E61B2B094E /* Pods */ = {
isa = PBXGroup;
children = (
@@ -173,26 +122,6 @@
productReference = 6369A26A1A9322E20015FC5C /* Sample.app */;
productType = "com.apple.product-type.application";
};
- 6369A2821A9322E20015FC5C /* SampleTests */ = {
- isa = PBXNativeTarget;
- buildConfigurationList = 6369A2901A9322E20015FC5C /* Build configuration list for PBXNativeTarget "SampleTests" */;
- buildPhases = (
- 75C393B2FDC60A22B2121058 /* Check Pods Manifest.lock */,
- 6369A27F1A9322E20015FC5C /* Sources */,
- 6369A2801A9322E20015FC5C /* Frameworks */,
- 6369A2811A9322E20015FC5C /* Resources */,
- 7B8CDC152F76D6014A96C798 /* Copy Pods Resources */,
- );
- buildRules = (
- );
- dependencies = (
- 6369A2851A9322E20015FC5C /* PBXTargetDependency */,
- );
- name = SampleTests;
- productName = SampleTests;
- productReference = 6369A2831A9322E20015FC5C /* SampleTests.xctest */;
- productType = "com.apple.product-type.bundle.unit-test";
- };
/* End PBXNativeTarget section */
/* Begin PBXProject section */
@@ -205,10 +134,6 @@
6369A2691A9322E20015FC5C = {
CreatedOnToolsVersion = 6.1.1;
};
- 6369A2821A9322E20015FC5C = {
- CreatedOnToolsVersion = 6.1.1;
- TestTargetID = 6369A2691A9322E20015FC5C;
- };
};
};
buildConfigurationList = 6369A2651A9322E20015FC5C /* Build configuration list for PBXProject "Sample" */;
@@ -225,7 +150,6 @@
projectRoot = "";
targets = (
6369A2691A9322E20015FC5C /* Sample */,
- 6369A2821A9322E20015FC5C /* SampleTests */,
);
};
/* End PBXProject section */
@@ -236,18 +160,10 @@
buildActionMask = 2147483647;
files = (
6369A2791A9322E20015FC5C /* Main.storyboard in Resources */,
- 6369A27E1A9322E20015FC5C /* LaunchScreen.xib in Resources */,
6369A27B1A9322E20015FC5C /* Images.xcassets in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
- 6369A2811A9322E20015FC5C /* Resources */ = {
- isa = PBXResourcesBuildPhase;
- buildActionMask = 2147483647;
- files = (
- );
- runOnlyForDeploymentPostprocessing = 0;
- };
/* End PBXResourcesBuildPhase section */
/* Begin PBXShellScriptBuildPhase section */
@@ -281,36 +197,6 @@
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n";
showEnvVarsInLog = 0;
};
- 75C393B2FDC60A22B2121058 /* Check Pods Manifest.lock */ = {
- isa = PBXShellScriptBuildPhase;
- buildActionMask = 2147483647;
- files = (
- );
- inputPaths = (
- );
- name = "Check Pods Manifest.lock";
- outputPaths = (
- );
- runOnlyForDeploymentPostprocessing = 0;
- shellPath = /bin/sh;
- shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n";
- showEnvVarsInLog = 0;
- };
- 7B8CDC152F76D6014A96C798 /* Copy Pods Resources */ = {
- isa = PBXShellScriptBuildPhase;
- buildActionMask = 2147483647;
- files = (
- );
- inputPaths = (
- );
- name = "Copy Pods Resources";
- outputPaths = (
- );
- runOnlyForDeploymentPostprocessing = 0;
- shellPath = /bin/sh;
- shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods/Pods-resources.sh\"\n";
- showEnvVarsInLog = 0;
- };
/* End PBXShellScriptBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
@@ -324,26 +210,8 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
- 6369A27F1A9322E20015FC5C /* Sources */ = {
- isa = PBXSourcesBuildPhase;
- buildActionMask = 2147483647;
- files = (
- 6369A28A1A9322E20015FC5C /* SampleTests.m in Sources */,
- 6340F0491AE66E3300FB6A3D /* RemoteProtoTests.m in Sources */,
- 6356D1DE1AC11FE00075FBBC /* RemoteTests.m in Sources */,
- );
- runOnlyForDeploymentPostprocessing = 0;
- };
/* End PBXSourcesBuildPhase section */
-/* Begin PBXTargetDependency section */
- 6369A2851A9322E20015FC5C /* PBXTargetDependency */ = {
- isa = PBXTargetDependency;
- target = 6369A2691A9322E20015FC5C /* Sample */;
- targetProxy = 6369A2841A9322E20015FC5C /* PBXContainerItemProxy */;
- };
-/* End PBXTargetDependency section */
-
/* Begin PBXVariantGroup section */
6369A2771A9322E20015FC5C /* Main.storyboard */ = {
isa = PBXVariantGroup;
@@ -353,14 +221,6 @@
name = Main.storyboard;
sourceTree = "<group>";
};
- 6369A27C1A9322E20015FC5C /* LaunchScreen.xib */ = {
- isa = PBXVariantGroup;
- children = (
- 6369A27D1A9322E20015FC5C /* Base */,
- );
- name = LaunchScreen.xib;
- sourceTree = "<group>";
- };
/* End PBXVariantGroup section */
/* Begin XCBuildConfiguration section */
@@ -464,42 +324,6 @@
};
name = Release;
};
- 6369A2911A9322E20015FC5C /* Debug */ = {
- isa = XCBuildConfiguration;
- baseConfigurationReference = AC29DD6FCDF962F519FEBB0D /* Pods.debug.xcconfig */;
- buildSettings = {
- BUNDLE_LOADER = "$(TEST_HOST)";
- FRAMEWORK_SEARCH_PATHS = (
- "$(SDKROOT)/Developer/Library/Frameworks",
- "$(inherited)",
- );
- GCC_PREPROCESSOR_DEFINITIONS = (
- "DEBUG=1",
- "$(inherited)",
- );
- INFOPLIST_FILE = SampleTests/Info.plist;
- LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
- PRODUCT_NAME = "$(TARGET_NAME)";
- TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Sample.app/Sample";
- };
- name = Debug;
- };
- 6369A2921A9322E20015FC5C /* Release */ = {
- isa = XCBuildConfiguration;
- baseConfigurationReference = C68330F8D451CC6ACEABA09F /* Pods.release.xcconfig */;
- buildSettings = {
- BUNDLE_LOADER = "$(TEST_HOST)";
- FRAMEWORK_SEARCH_PATHS = (
- "$(SDKROOT)/Developer/Library/Frameworks",
- "$(inherited)",
- );
- INFOPLIST_FILE = SampleTests/Info.plist;
- LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
- PRODUCT_NAME = "$(TARGET_NAME)";
- TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Sample.app/Sample";
- };
- name = Release;
- };
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
@@ -521,15 +345,6 @@
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
- 6369A2901A9322E20015FC5C /* Build configuration list for PBXNativeTarget "SampleTests" */ = {
- isa = XCConfigurationList;
- buildConfigurations = (
- 6369A2911A9322E20015FC5C /* Debug */,
- 6369A2921A9322E20015FC5C /* Release */,
- );
- defaultConfigurationIsVisible = 0;
- defaultConfigurationName = Release;
- };
/* End XCConfigurationList section */
};
rootObject = 6369A2621A9322E20015FC5C /* Project object */;
diff --git a/src/objective-c/examples/Sample/Sample/AppDelegate.h b/src/objective-c/examples/Sample/Sample/AppDelegate.h
index b1857f28e0..102e7f3ade 100644
--- a/src/objective-c/examples/Sample/Sample/AppDelegate.h
+++ b/src/objective-c/examples/Sample/Sample/AppDelegate.h
@@ -34,8 +34,5 @@
#import <UIKit/UIKit.h>
@interface AppDelegate : UIResponder <UIApplicationDelegate>
-
@property (strong, nonatomic) UIWindow *window;
-
@end
-
diff --git a/src/objective-c/examples/Sample/Sample/AppDelegate.m b/src/objective-c/examples/Sample/Sample/AppDelegate.m
index 12e1ad9d67..a38e36651e 100644
--- a/src/objective-c/examples/Sample/Sample/AppDelegate.m
+++ b/src/objective-c/examples/Sample/Sample/AppDelegate.m
@@ -33,13 +33,5 @@
#import "AppDelegate.h"
-@interface AppDelegate ()
-@end
-
@implementation AppDelegate
-
-- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
- return YES;
-}
-
@end
diff --git a/src/objective-c/examples/Sample/Sample/Base.lproj/LaunchScreen.xib b/src/objective-c/examples/Sample/Sample/Base.lproj/LaunchScreen.xib
deleted file mode 100644
index c51a8e199e..0000000000
--- a/src/objective-c/examples/Sample/Sample/Base.lproj/LaunchScreen.xib
+++ /dev/null
@@ -1,41 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="6214" systemVersion="14A314h" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES">
- <dependencies>
- <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6207"/>
- <capability name="Constraints with non-1.0 multipliers" minToolsVersion="5.1"/>
- </dependencies>
- <objects>
- <placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
- <placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
- <view contentMode="scaleToFill" id="iN0-l3-epB">
- <rect key="frame" x="0.0" y="0.0" width="480" height="480"/>
- <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
- <subviews>
- <label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text=" Copyright (c) 2015 gRPC. All rights reserved." textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" minimumFontSize="9" translatesAutoresizingMaskIntoConstraints="NO" id="8ie-xW-0ye">
- <rect key="frame" x="20" y="439" width="441" height="21"/>
- <fontDescription key="fontDescription" type="system" pointSize="17"/>
- <color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
- <nil key="highlightedColor"/>
- </label>
- <label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Sample" textAlignment="center" lineBreakMode="middleTruncation" baselineAdjustment="alignBaselines" minimumFontSize="18" translatesAutoresizingMaskIntoConstraints="NO" id="kId-c2-rCX">
- <rect key="frame" x="20" y="140" width="441" height="43"/>
- <fontDescription key="fontDescription" type="boldSystem" pointSize="36"/>
- <color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
- <nil key="highlightedColor"/>
- </label>
- </subviews>
- <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
- <constraints>
- <constraint firstItem="kId-c2-rCX" firstAttribute="centerY" secondItem="iN0-l3-epB" secondAttribute="bottom" multiplier="1/3" constant="1" id="5cJ-9S-tgC"/>
- <constraint firstAttribute="centerX" secondItem="kId-c2-rCX" secondAttribute="centerX" id="Koa-jz-hwk"/>
- <constraint firstAttribute="bottom" secondItem="8ie-xW-0ye" secondAttribute="bottom" constant="20" id="Kzo-t9-V3l"/>
- <constraint firstItem="8ie-xW-0ye" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" constant="20" symbolic="YES" id="MfP-vx-nX0"/>
- <constraint firstAttribute="centerX" secondItem="8ie-xW-0ye" secondAttribute="centerX" id="ZEH-qu-HZ9"/>
- <constraint firstItem="kId-c2-rCX" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" constant="20" symbolic="YES" id="fvb-Df-36g"/>
- </constraints>
- <nil key="simulatedStatusBarMetrics"/>
- <freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
- <point key="canvasLocation" x="548" y="455"/>
- </view>
- </objects>
-</document>
diff --git a/src/objective-c/examples/Sample/Sample/Base.lproj/Main.storyboard b/src/objective-c/examples/Sample/Sample/Base.lproj/Main.storyboard
index f56d2f3bb5..8887b9e19f 100644
--- a/src/objective-c/examples/Sample/Sample/Base.lproj/Main.storyboard
+++ b/src/objective-c/examples/Sample/Sample/Base.lproj/Main.storyboard
@@ -1,13 +1,14 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="6211" systemVersion="14A298i" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="BYZ-38-t0r">
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="7702" systemVersion="14D131" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="BYZ-38-t0r">
<dependencies>
- <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6204"/>
+ <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="7701"/>
+ <capability name="Constraints to layout margins" minToolsVersion="6.0"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="tne-QT-ifu">
<objects>
- <viewController id="BYZ-38-t0r" customClass="ViewController" customModuleProvider="" sceneMemberID="viewController">
+ <viewController id="BYZ-38-t0r" customClass="ViewController" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="y3c-jy-aDJ"/>
<viewControllerLayoutGuide type="bottom" id="wfy-db-euE"/>
@@ -15,7 +16,38 @@
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+ <subviews>
+ <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" misplaced="YES" lineBreakMode="wordWrap" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="BWr-eN-L3y">
+ <rect key="frame" x="16" y="20" width="568" height="150"/>
+ <constraints>
+ <constraint firstAttribute="width" constant="385" id="exg-IV-Kl0"/>
+ </constraints>
+ <string key="text">Sample app launch finished.
+Check ViewController.m for the gRPC calls made, and the logs of this app for their results.
+(You may need to make XCode's Debug Area visible).</string>
+ <fontDescription key="fontDescription" type="system" pointSize="17"/>
+ <color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
+ <nil key="highlightedColor"/>
+ <variation key="default">
+ <mask key="constraints">
+ <exclude reference="exg-IV-Kl0"/>
+ </mask>
+ </variation>
+ </label>
+ </subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
+ <constraints>
+ <constraint firstItem="wfy-db-euE" firstAttribute="top" secondItem="BWr-eN-L3y" secondAttribute="bottom" constant="430" id="KFC-7p-hRl"/>
+ <constraint firstAttribute="trailing" secondItem="BWr-eN-L3y" secondAttribute="trailing" constant="16" id="M9C-nN-tFv"/>
+ <constraint firstItem="BWr-eN-L3y" firstAttribute="leading" secondItem="8bC-Xf-vdC" secondAttribute="leadingMargin" id="SaP-0S-2LK"/>
+ <constraint firstItem="wfy-db-euE" firstAttribute="top" secondItem="BWr-eN-L3y" secondAttribute="bottom" id="wjC-O4-kJg"/>
+ <constraint firstItem="BWr-eN-L3y" firstAttribute="top" secondItem="y3c-jy-aDJ" secondAttribute="bottom" id="ygF-6t-hrg"/>
+ </constraints>
+ <variation key="default">
+ <mask key="constraints">
+ <exclude reference="KFC-7p-hRl"/>
+ </mask>
+ </variation>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
diff --git a/src/objective-c/examples/Sample/Sample/Info.plist b/src/objective-c/examples/Sample/Sample/Info.plist
index ffdc8b3012..4436635ab4 100644
--- a/src/objective-c/examples/Sample/Sample/Info.plist
+++ b/src/objective-c/examples/Sample/Sample/Info.plist
@@ -23,7 +23,7 @@
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UILaunchStoryboardName</key>
- <string>LaunchScreen</string>
+ <string>Main</string>
<key>UIMainStoryboardFile</key>
<string>Main</string>
<key>UIRequiredDeviceCapabilities</key>
diff --git a/src/objective-c/examples/Sample/Sample/ViewController.m b/src/objective-c/examples/Sample/Sample/ViewController.m
index 9b331fe43f..0011a4508d 100644
--- a/src/objective-c/examples/Sample/Sample/ViewController.m
+++ b/src/objective-c/examples/Sample/Sample/ViewController.m
@@ -40,9 +40,6 @@
#import <RemoteTest/Messages.pbobjc.h>
#import <RemoteTest/Test.pbrpc.h>
-@interface ViewController ()
-@end
-
@implementation ViewController
- (void)viewDidLoad {
diff --git a/src/objective-c/examples/Sample/RemoteTestClient/Empty.pbobjc.h b/src/objective-c/generated_libraries/RemoteTestClient/Empty.pbobjc.h
index 809d0dde6e..809d0dde6e 100644
--- a/src/objective-c/examples/Sample/RemoteTestClient/Empty.pbobjc.h
+++ b/src/objective-c/generated_libraries/RemoteTestClient/Empty.pbobjc.h
diff --git a/src/objective-c/examples/Sample/RemoteTestClient/Empty.pbobjc.m b/src/objective-c/generated_libraries/RemoteTestClient/Empty.pbobjc.m
index 46d481af66..46d481af66 100644
--- a/src/objective-c/examples/Sample/RemoteTestClient/Empty.pbobjc.m
+++ b/src/objective-c/generated_libraries/RemoteTestClient/Empty.pbobjc.m
diff --git a/src/objective-c/examples/Sample/RemoteTestClient/Messages.pbobjc.h b/src/objective-c/generated_libraries/RemoteTestClient/Messages.pbobjc.h
index 5f32314175..5f32314175 100644
--- a/src/objective-c/examples/Sample/RemoteTestClient/Messages.pbobjc.h
+++ b/src/objective-c/generated_libraries/RemoteTestClient/Messages.pbobjc.h
diff --git a/src/objective-c/examples/Sample/RemoteTestClient/Messages.pbobjc.m b/src/objective-c/generated_libraries/RemoteTestClient/Messages.pbobjc.m
index 98eb1dc87c..98eb1dc87c 100644
--- a/src/objective-c/examples/Sample/RemoteTestClient/Messages.pbobjc.m
+++ b/src/objective-c/generated_libraries/RemoteTestClient/Messages.pbobjc.m
diff --git a/src/objective-c/examples/Sample/RemoteTestClient/RemoteTest.podspec b/src/objective-c/generated_libraries/RemoteTestClient/RemoteTest.podspec
index 36c2b509e8..36c2b509e8 100644
--- a/src/objective-c/examples/Sample/RemoteTestClient/RemoteTest.podspec
+++ b/src/objective-c/generated_libraries/RemoteTestClient/RemoteTest.podspec
diff --git a/src/objective-c/examples/Sample/RemoteTestClient/Test.pbobjc.h b/src/objective-c/generated_libraries/RemoteTestClient/Test.pbobjc.h
index aaa0b6ce2d..aaa0b6ce2d 100644
--- a/src/objective-c/examples/Sample/RemoteTestClient/Test.pbobjc.h
+++ b/src/objective-c/generated_libraries/RemoteTestClient/Test.pbobjc.h
diff --git a/src/objective-c/examples/Sample/RemoteTestClient/Test.pbobjc.m b/src/objective-c/generated_libraries/RemoteTestClient/Test.pbobjc.m
index 08562b828a..08562b828a 100644
--- a/src/objective-c/examples/Sample/RemoteTestClient/Test.pbobjc.m
+++ b/src/objective-c/generated_libraries/RemoteTestClient/Test.pbobjc.m
diff --git a/src/objective-c/examples/Sample/RemoteTestClient/Test.pbrpc.h b/src/objective-c/generated_libraries/RemoteTestClient/Test.pbrpc.h
index f799c4fc92..f799c4fc92 100644
--- a/src/objective-c/examples/Sample/RemoteTestClient/Test.pbrpc.h
+++ b/src/objective-c/generated_libraries/RemoteTestClient/Test.pbrpc.h
diff --git a/src/objective-c/examples/Sample/RemoteTestClient/Test.pbrpc.m b/src/objective-c/generated_libraries/RemoteTestClient/Test.pbrpc.m
index faba07769e..faba07769e 100644
--- a/src/objective-c/examples/Sample/RemoteTestClient/Test.pbrpc.m
+++ b/src/objective-c/generated_libraries/RemoteTestClient/Test.pbrpc.m
diff --git a/src/objective-c/examples/Sample/RemoteTestClient/empty.proto b/src/objective-c/generated_libraries/RemoteTestClient/empty.proto
index a678048289..a678048289 100644
--- a/src/objective-c/examples/Sample/RemoteTestClient/empty.proto
+++ b/src/objective-c/generated_libraries/RemoteTestClient/empty.proto
diff --git a/src/objective-c/examples/Sample/RemoteTestClient/messages.proto b/src/objective-c/generated_libraries/RemoteTestClient/messages.proto
index 85d93c2ff9..85d93c2ff9 100644
--- a/src/objective-c/examples/Sample/RemoteTestClient/messages.proto
+++ b/src/objective-c/generated_libraries/RemoteTestClient/messages.proto
diff --git a/src/objective-c/examples/Sample/RemoteTestClient/test.proto b/src/objective-c/generated_libraries/RemoteTestClient/test.proto
index 2f5a5489b3..2f5a5489b3 100644
--- a/src/objective-c/examples/Sample/RemoteTestClient/test.proto
+++ b/src/objective-c/generated_libraries/RemoteTestClient/test.proto
diff --git a/src/objective-c/examples/Sample/RouteGuideClient/RouteGuide.pbobjc.h b/src/objective-c/generated_libraries/RouteGuideClient/RouteGuide.pbobjc.h
index 6efaec7f02..6efaec7f02 100644
--- a/src/objective-c/examples/Sample/RouteGuideClient/RouteGuide.pbobjc.h
+++ b/src/objective-c/generated_libraries/RouteGuideClient/RouteGuide.pbobjc.h
diff --git a/src/objective-c/examples/Sample/RouteGuideClient/RouteGuide.pbobjc.m b/src/objective-c/generated_libraries/RouteGuideClient/RouteGuide.pbobjc.m
index 16f291a61c..16f291a61c 100644
--- a/src/objective-c/examples/Sample/RouteGuideClient/RouteGuide.pbobjc.m
+++ b/src/objective-c/generated_libraries/RouteGuideClient/RouteGuide.pbobjc.m
diff --git a/src/objective-c/examples/Sample/RouteGuideClient/RouteGuide.pbrpc.h b/src/objective-c/generated_libraries/RouteGuideClient/RouteGuide.pbrpc.h
index 9e60865d98..9e60865d98 100644
--- a/src/objective-c/examples/Sample/RouteGuideClient/RouteGuide.pbrpc.h
+++ b/src/objective-c/generated_libraries/RouteGuideClient/RouteGuide.pbrpc.h
diff --git a/src/objective-c/examples/Sample/RouteGuideClient/RouteGuide.pbrpc.m b/src/objective-c/generated_libraries/RouteGuideClient/RouteGuide.pbrpc.m
index 2ca3dc6768..2ca3dc6768 100644
--- a/src/objective-c/examples/Sample/RouteGuideClient/RouteGuide.pbrpc.m
+++ b/src/objective-c/generated_libraries/RouteGuideClient/RouteGuide.pbrpc.m
diff --git a/src/objective-c/examples/Sample/RouteGuideClient/Route_guide.podspec b/src/objective-c/generated_libraries/RouteGuideClient/Route_guide.podspec
index 5b1a68aad5..5b1a68aad5 100644
--- a/src/objective-c/examples/Sample/RouteGuideClient/Route_guide.podspec
+++ b/src/objective-c/generated_libraries/RouteGuideClient/Route_guide.podspec
diff --git a/src/objective-c/examples/Sample/RouteGuideClient/route_guide.proto b/src/objective-c/generated_libraries/RouteGuideClient/route_guide.proto
index 16dce26a2b..16dce26a2b 100644
--- a/src/objective-c/examples/Sample/RouteGuideClient/route_guide.proto
+++ b/src/objective-c/generated_libraries/RouteGuideClient/route_guide.proto
diff --git a/src/objective-c/examples/Sample/SampleTests/RemoteTests.m b/src/objective-c/tests/GRPCClientTests.m
index ceb72cfaec..713ea2848a 100644
--- a/src/objective-c/examples/Sample/SampleTests/RemoteTests.m
+++ b/src/objective-c/tests/GRPCClientTests.m
@@ -40,10 +40,13 @@
#import <gRPC/GRXWriteable.h>
#import <RemoteTest/Messages.pbobjc.h>
-@interface RemoteTests : XCTestCase
+// These are a few tests similar to InteropTests, but which use the generic gRPC client (GRPCCall)
+// rather than a generated proto library on top of it.
+
+@interface GRPCClientTests : XCTestCase
@end
-@implementation RemoteTests
+@implementation GRPCClientTests
- (void)testConnectionToRemoteServer {
__weak XCTestExpectation *expectation = [self expectationWithDescription:@"Server reachable."];
diff --git a/src/objective-c/examples/Sample/SampleTests/Info.plist b/src/objective-c/tests/Info.plist
index f547b0b707..fbeeb96ba6 100644
--- a/src/objective-c/examples/Sample/SampleTests/Info.plist
+++ b/src/objective-c/tests/Info.plist
@@ -7,7 +7,7 @@
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
- <string>org.grpc.$(PRODUCT_NAME:rfc1034identifier)</string>
+ <string>gRPC.$(PRODUCT_NAME:rfc1034identifier)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
diff --git a/src/objective-c/examples/Sample/SampleTests/RemoteProtoTests.m b/src/objective-c/tests/InteropTests.m
index 8e0e11d23d..0a512c17dc 100644
--- a/src/objective-c/examples/Sample/SampleTests/RemoteProtoTests.m
+++ b/src/objective-c/tests/InteropTests.m
@@ -76,10 +76,10 @@
}
@end
-@interface RemoteProtoTests : XCTestCase
+@interface InteropTests : XCTestCase
@end
-@implementation RemoteProtoTests {
+@implementation InteropTests {
RMTTestService *_service;
}
@@ -192,7 +192,7 @@
[expectation fulfill];
}
}];
-
+
[self waitForExpectationsWithTimeout:4 handler:nil];
}
@@ -230,7 +230,7 @@
[requestsBuffer writesFinishedWithError:nil];
}
}
-
+
if (done) {
XCTAssertEqual(index, 4, @"Received %i responses instead of 4.", index);
[expectation fulfill];
@@ -283,9 +283,9 @@
[requestsBuffer writeValue:request];
__block ProtoRPC *call = [_service RPCToFullDuplexCallWithRequestsWriter:requestsBuffer
- handler:^(BOOL done,
- RMTStreamingOutputCallResponse *response,
- NSError *error) {
+ handler:^(BOOL done,
+ RMTStreamingOutputCallResponse *response,
+ NSError *error) {
if (receivedResponse) {
XCTAssert(done, @"Unexpected extra response %@", response);
XCTAssertEqual(error.code, GRPC_STATUS_CANCELLED);
diff --git a/src/objective-c/examples/Sample/SampleTests/SampleTests.m b/src/objective-c/tests/LocalClearTextTests.m
index 83cfd8c1b5..6a9496b623 100644
--- a/src/objective-c/examples/Sample/SampleTests/SampleTests.m
+++ b/src/objective-c/tests/LocalClearTextTests.m
@@ -41,13 +41,14 @@
#import <Route_guide/RouteGuide.pbobjc.h>
#import <Route_guide/RouteGuide.pbrpc.h>
-@interface SampleTests : XCTestCase
+// These tests require the gRPC-Java "RouteGuide" sample server to be running locally. To do so,
+// install Gradle by following the instructions here: https://docs.gradle.org/current/userguide/installation.html
+// And use it to run the server by following the instructions here: https://github.com/grpc/grpc-java/tree/master/examples
+
+@interface LocalClearTextTests : XCTestCase
@end
-// These tests require the gRPC-Java "RouteGuide" sample server to be running locally. Install the
-// gRPC-Java library following the instructions here: https://github.com/grpc/grpc-java And run the
-// server by following the instructions here: https://github.com/grpc/grpc-java/tree/master/examples
-@implementation SampleTests
+@implementation LocalClearTextTests
- (void)testConnectionToLocalServer {
__weak XCTestExpectation *expectation = [self expectationWithDescription:@"Server reachable."];
diff --git a/src/objective-c/tests/Podfile b/src/objective-c/tests/Podfile
new file mode 100644
index 0000000000..c099fb5182
--- /dev/null
+++ b/src/objective-c/tests/Podfile
@@ -0,0 +1,15 @@
+source 'https://github.com/CocoaPods/Specs.git'
+platform :ios, '8.0'
+
+pod 'gRPC', :path => "../../.."
+pod 'Protobuf', :git => 'https://github.com/google/protobuf.git'
+pod 'RemoteTest', :path => "../generated_libraries/RemoteTestClient"
+pod 'Route_guide', :path => "../generated_libraries/RouteGuideClient"
+
+link_with 'AllTests'
+
+target 'Tests' do
+end
+
+target 'AllTests' do
+end
diff --git a/src/objective-c/tests/RxLibraryUnitTests.m b/src/objective-c/tests/RxLibraryUnitTests.m
new file mode 100644
index 0000000000..89984d9481
--- /dev/null
+++ b/src/objective-c/tests/RxLibraryUnitTests.m
@@ -0,0 +1,140 @@
+/*
+ *
+ * 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.
+ *
+ */
+
+#import <UIKit/UIKit.h>
+#import <XCTest/XCTest.h>
+
+#import <gRPC/GRXBufferedPipe.h>
+#import <gRPC/GRXWriter.h>
+#import <gRPC/GRXWriteable.h>
+
+// A mock of a GRXSingleValueHandler block that can be queried for how many times it was called and
+// what were the last values passed to it.
+//
+// TODO(jcanizales): Move this to a test util library, and add tests for it.
+@interface CapturingSingleValueHandler : NSObject
+@property (nonatomic, readonly) void (^block)(id value, NSError *errorOrNil);
+@property (nonatomic, readonly) NSUInteger timesCalled;
+@property (nonatomic, readonly) id value;
+@property (nonatomic, readonly) NSError *errorOrNil;
++ (instancetype)handler;
+@end
+
+@implementation CapturingSingleValueHandler
++ (instancetype)handler {
+ return [[self alloc] init];
+}
+
+- (GRXSingleValueHandler)block {
+ return ^(id value, NSError *errorOrNil) {
+ ++_timesCalled;
+ _value = value;
+ _errorOrNil = errorOrNil;
+ };
+}
+@end
+
+@interface RxLibraryUnitTests : XCTestCase
+@end
+
+@implementation RxLibraryUnitTests
+
+#pragma mark Writeable
+
+- (void)testWriteableSingleValueHandlerIsCalledForValue {
+ // Given:
+ CapturingSingleValueHandler *handler = [CapturingSingleValueHandler handler];
+ id anyValue = @7;
+
+ // If:
+ id<GRXWriteable> writeable = [GRXWriteable writeableWithSingleValueHandler:handler.block];
+ [writeable writeValue:anyValue];
+
+ // Then:
+ XCTAssertEqual(handler.timesCalled, 1);
+ XCTAssertEqualObjects(handler.value, anyValue);
+ XCTAssertEqualObjects(handler.errorOrNil, nil);
+}
+
+- (void)testWriteableSingleValueHandlerIsCalledForError {
+ // Given:
+ CapturingSingleValueHandler *handler = [CapturingSingleValueHandler handler];
+ NSError *anyError = [NSError errorWithDomain:@"domain" code:7 userInfo:nil];
+
+ // If:
+ id<GRXWriteable> writeable = [GRXWriteable writeableWithSingleValueHandler:handler.block];
+ [writeable writesFinishedWithError:anyError];
+
+ // Then:
+ XCTAssertEqual(handler.timesCalled, 1);
+ XCTAssertEqualObjects(handler.value, nil);
+ XCTAssertEqualObjects(handler.errorOrNil, anyError);
+}
+
+#pragma mark BufferedPipe
+
+- (void)testBufferedPipePropagatesValue {
+ // Given:
+ CapturingSingleValueHandler *handler = [CapturingSingleValueHandler handler];
+ id<GRXWriteable> writeable = [GRXWriteable writeableWithSingleValueHandler:handler.block];
+ id anyValue = @7;
+
+ // If:
+ GRXBufferedPipe *pipe = [GRXBufferedPipe pipe];
+ [pipe startWithWriteable:writeable];
+ [pipe writeValue:anyValue];
+
+ // Then:
+ XCTAssertEqual(handler.timesCalled, 1);
+ XCTAssertEqualObjects(handler.value, anyValue);
+ XCTAssertEqualObjects(handler.errorOrNil, nil);
+}
+
+- (void)testBufferedPipePropagatesError {
+ // Given:
+ CapturingSingleValueHandler *handler = [CapturingSingleValueHandler handler];
+ id<GRXWriteable> writeable = [GRXWriteable writeableWithSingleValueHandler:handler.block];
+ NSError *anyError = [NSError errorWithDomain:@"domain" code:7 userInfo:nil];
+
+ // If:
+ GRXBufferedPipe *pipe = [GRXBufferedPipe pipe];
+ [pipe startWithWriteable:writeable];
+ [pipe writesFinishedWithError:anyError];
+
+ // Then:
+ XCTAssertEqual(handler.timesCalled, 1);
+ XCTAssertEqualObjects(handler.value, nil);
+ XCTAssertEqualObjects(handler.errorOrNil, anyError);
+}
+
+@end
diff --git a/src/objective-c/tests/Tests.m b/src/objective-c/tests/Tests.m
new file mode 100644
index 0000000000..b821d38720
--- /dev/null
+++ b/src/objective-c/tests/Tests.m
@@ -0,0 +1,40 @@
+/*
+ *
+ * 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.
+ *
+ */
+
+#import <Foundation/Foundation.h>
+
+@interface Tests : NSObject
+@end
+
+@implementation Tests
+@end
diff --git a/src/objective-c/tests/Tests.xcodeproj/project.pbxproj b/src/objective-c/tests/Tests.xcodeproj/project.pbxproj
new file mode 100644
index 0000000000..34be705db2
--- /dev/null
+++ b/src/objective-c/tests/Tests.xcodeproj/project.pbxproj
@@ -0,0 +1,442 @@
+// !$*UTF8*$!
+{
+ archiveVersion = 1;
+ classes = {
+ };
+ objectVersion = 46;
+ objects = {
+
+/* Begin PBXBuildFile section */
+ 6312AE4E1B1BF49B00341DEE /* GRPCClientTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 6312AE4D1B1BF49B00341DEE /* GRPCClientTests.m */; };
+ 63175DFF1B1B9FAF00027841 /* LocalClearTextTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 63175DFE1B1B9FAF00027841 /* LocalClearTextTests.m */; };
+ 63423F4A1B150A5F006CF63C /* libTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 635697C71B14FC11007A7283 /* libTests.a */; };
+ 63423F511B151B77006CF63C /* RxLibraryUnitTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 63423F501B151B77006CF63C /* RxLibraryUnitTests.m */; };
+ 635697CD1B14FC11007A7283 /* Tests.m in Sources */ = {isa = PBXBuildFile; fileRef = 635697CC1B14FC11007A7283 /* Tests.m */; };
+ 635ED2EC1B1A3BC400FDE5C3 /* InteropTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 635ED2EB1B1A3BC400FDE5C3 /* InteropTests.m */; };
+ 7D8A186224D39101F90230F6 /* libPods.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 35F2B6BF3BAE8F0DC4AFD76E /* libPods.a */; };
+/* End PBXBuildFile section */
+
+/* Begin PBXContainerItemProxy section */
+ 63423F4B1B150A5F006CF63C /* PBXContainerItemProxy */ = {
+ isa = PBXContainerItemProxy;
+ containerPortal = 635697BF1B14FC11007A7283 /* Project object */;
+ proxyType = 1;
+ remoteGlobalIDString = 635697C61B14FC11007A7283;
+ remoteInfo = Tests;
+ };
+/* End PBXContainerItemProxy section */
+
+/* Begin PBXCopyFilesBuildPhase section */
+ 635697C51B14FC11007A7283 /* CopyFiles */ = {
+ isa = PBXCopyFilesBuildPhase;
+ buildActionMask = 2147483647;
+ dstPath = "include/$(PRODUCT_NAME)";
+ dstSubfolderSpec = 16;
+ files = (
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXCopyFilesBuildPhase section */
+
+/* Begin PBXFileReference section */
+ 0A4F89D9C90E9C30990218F0 /* Pods.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.release.xcconfig; path = "Pods/Target Support Files/Pods/Pods.release.xcconfig"; sourceTree = "<group>"; };
+ 35F2B6BF3BAE8F0DC4AFD76E /* libPods.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libPods.a; sourceTree = BUILT_PRODUCTS_DIR; };
+ 6312AE4D1B1BF49B00341DEE /* GRPCClientTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GRPCClientTests.m; sourceTree = "<group>"; };
+ 63175DFE1B1B9FAF00027841 /* LocalClearTextTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LocalClearTextTests.m; sourceTree = "<group>"; };
+ 63423F441B150A5F006CF63C /* AllTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = AllTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
+ 63423F501B151B77006CF63C /* RxLibraryUnitTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RxLibraryUnitTests.m; sourceTree = "<group>"; };
+ 635697C71B14FC11007A7283 /* libTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libTests.a; sourceTree = BUILT_PRODUCTS_DIR; };
+ 635697CC1B14FC11007A7283 /* Tests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = Tests.m; sourceTree = "<group>"; };
+ 635697D81B14FC11007A7283 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
+ 635ED2EB1B1A3BC400FDE5C3 /* InteropTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = InteropTests.m; sourceTree = "<group>"; };
+ FF7B5489BCFE40111D768DD0 /* Pods.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.debug.xcconfig; path = "Pods/Target Support Files/Pods/Pods.debug.xcconfig"; sourceTree = "<group>"; };
+/* End PBXFileReference section */
+
+/* Begin PBXFrameworksBuildPhase section */
+ 63423F411B150A5F006CF63C /* Frameworks */ = {
+ isa = PBXFrameworksBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 63423F4A1B150A5F006CF63C /* libTests.a in Frameworks */,
+ 7D8A186224D39101F90230F6 /* libPods.a in Frameworks */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+ 635697C41B14FC11007A7283 /* Frameworks */ = {
+ isa = PBXFrameworksBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXFrameworksBuildPhase section */
+
+/* Begin PBXGroup section */
+ 136D535E19727099B941D7B1 /* Frameworks */ = {
+ isa = PBXGroup;
+ children = (
+ 35F2B6BF3BAE8F0DC4AFD76E /* libPods.a */,
+ );
+ name = Frameworks;
+ sourceTree = "<group>";
+ };
+ 51E4650F34F854F41FF053B3 /* Pods */ = {
+ isa = PBXGroup;
+ children = (
+ FF7B5489BCFE40111D768DD0 /* Pods.debug.xcconfig */,
+ 0A4F89D9C90E9C30990218F0 /* Pods.release.xcconfig */,
+ );
+ name = Pods;
+ sourceTree = "<group>";
+ };
+ 635697BE1B14FC11007A7283 = {
+ isa = PBXGroup;
+ children = (
+ 635697C91B14FC11007A7283 /* Tests */,
+ 635697C81B14FC11007A7283 /* Products */,
+ 51E4650F34F854F41FF053B3 /* Pods */,
+ 136D535E19727099B941D7B1 /* Frameworks */,
+ );
+ sourceTree = "<group>";
+ };
+ 635697C81B14FC11007A7283 /* Products */ = {
+ isa = PBXGroup;
+ children = (
+ 635697C71B14FC11007A7283 /* libTests.a */,
+ 63423F441B150A5F006CF63C /* AllTests.xctest */,
+ );
+ name = Products;
+ sourceTree = "<group>";
+ };
+ 635697C91B14FC11007A7283 /* Tests */ = {
+ isa = PBXGroup;
+ children = (
+ 6312AE4D1B1BF49B00341DEE /* GRPCClientTests.m */,
+ 63175DFE1B1B9FAF00027841 /* LocalClearTextTests.m */,
+ 635ED2EB1B1A3BC400FDE5C3 /* InteropTests.m */,
+ 63423F501B151B77006CF63C /* RxLibraryUnitTests.m */,
+ 635697CC1B14FC11007A7283 /* Tests.m */,
+ 635697D71B14FC11007A7283 /* Supporting Files */,
+ );
+ name = Tests;
+ sourceTree = SOURCE_ROOT;
+ };
+ 635697D71B14FC11007A7283 /* Supporting Files */ = {
+ isa = PBXGroup;
+ children = (
+ 635697D81B14FC11007A7283 /* Info.plist */,
+ );
+ name = "Supporting Files";
+ sourceTree = "<group>";
+ };
+/* End PBXGroup section */
+
+/* Begin PBXNativeTarget section */
+ 63423F431B150A5F006CF63C /* AllTests */ = {
+ isa = PBXNativeTarget;
+ buildConfigurationList = 63423F4D1B150A5F006CF63C /* Build configuration list for PBXNativeTarget "AllTests" */;
+ buildPhases = (
+ 914ADDD7106BA9BB8A7E569F /* Check Pods Manifest.lock */,
+ 63423F401B150A5F006CF63C /* Sources */,
+ 63423F411B150A5F006CF63C /* Frameworks */,
+ 63423F421B150A5F006CF63C /* Resources */,
+ A441F71824DCB9D0CA297748 /* Copy Pods Resources */,
+ );
+ buildRules = (
+ );
+ dependencies = (
+ 63423F4C1B150A5F006CF63C /* PBXTargetDependency */,
+ );
+ name = AllTests;
+ productName = AllTests;
+ productReference = 63423F441B150A5F006CF63C /* AllTests.xctest */;
+ productType = "com.apple.product-type.bundle.unit-test";
+ };
+ 635697C61B14FC11007A7283 /* Tests */ = {
+ isa = PBXNativeTarget;
+ buildConfigurationList = 635697DB1B14FC11007A7283 /* Build configuration list for PBXNativeTarget "Tests" */;
+ buildPhases = (
+ 635697C31B14FC11007A7283 /* Sources */,
+ 635697C41B14FC11007A7283 /* Frameworks */,
+ 635697C51B14FC11007A7283 /* CopyFiles */,
+ );
+ buildRules = (
+ );
+ dependencies = (
+ );
+ name = Tests;
+ productName = Tests;
+ productReference = 635697C71B14FC11007A7283 /* libTests.a */;
+ productType = "com.apple.product-type.library.static";
+ };
+/* End PBXNativeTarget section */
+
+/* Begin PBXProject section */
+ 635697BF1B14FC11007A7283 /* Project object */ = {
+ isa = PBXProject;
+ attributes = {
+ LastUpgradeCheck = 0630;
+ ORGANIZATIONNAME = gRPC;
+ TargetAttributes = {
+ 63423F431B150A5F006CF63C = {
+ CreatedOnToolsVersion = 6.3.1;
+ };
+ 635697C61B14FC11007A7283 = {
+ CreatedOnToolsVersion = 6.3.1;
+ };
+ };
+ };
+ buildConfigurationList = 635697C21B14FC11007A7283 /* Build configuration list for PBXProject "Tests" */;
+ compatibilityVersion = "Xcode 3.2";
+ developmentRegion = English;
+ hasScannedForEncodings = 0;
+ knownRegions = (
+ en,
+ );
+ mainGroup = 635697BE1B14FC11007A7283;
+ productRefGroup = 635697C81B14FC11007A7283 /* Products */;
+ projectDirPath = "";
+ projectRoot = "";
+ targets = (
+ 635697C61B14FC11007A7283 /* Tests */,
+ 63423F431B150A5F006CF63C /* AllTests */,
+ );
+ };
+/* End PBXProject section */
+
+/* Begin PBXResourcesBuildPhase section */
+ 63423F421B150A5F006CF63C /* Resources */ = {
+ isa = PBXResourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXResourcesBuildPhase section */
+
+/* Begin PBXShellScriptBuildPhase section */
+ 914ADDD7106BA9BB8A7E569F /* Check Pods Manifest.lock */ = {
+ isa = PBXShellScriptBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ inputPaths = (
+ );
+ name = "Check Pods Manifest.lock";
+ outputPaths = (
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ shellPath = /bin/sh;
+ shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n";
+ showEnvVarsInLog = 0;
+ };
+ A441F71824DCB9D0CA297748 /* Copy Pods Resources */ = {
+ isa = PBXShellScriptBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ inputPaths = (
+ );
+ name = "Copy Pods Resources";
+ outputPaths = (
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ shellPath = /bin/sh;
+ shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods/Pods-resources.sh\"\n";
+ showEnvVarsInLog = 0;
+ };
+/* End PBXShellScriptBuildPhase section */
+
+/* Begin PBXSourcesBuildPhase section */
+ 63423F401B150A5F006CF63C /* Sources */ = {
+ isa = PBXSourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 63175DFF1B1B9FAF00027841 /* LocalClearTextTests.m in Sources */,
+ 63423F511B151B77006CF63C /* RxLibraryUnitTests.m in Sources */,
+ 6312AE4E1B1BF49B00341DEE /* GRPCClientTests.m in Sources */,
+ 635ED2EC1B1A3BC400FDE5C3 /* InteropTests.m in Sources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+ 635697C31B14FC11007A7283 /* Sources */ = {
+ isa = PBXSourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 635697CD1B14FC11007A7283 /* Tests.m in Sources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXSourcesBuildPhase section */
+
+/* Begin PBXTargetDependency section */
+ 63423F4C1B150A5F006CF63C /* PBXTargetDependency */ = {
+ isa = PBXTargetDependency;
+ target = 635697C61B14FC11007A7283 /* Tests */;
+ targetProxy = 63423F4B1B150A5F006CF63C /* PBXContainerItemProxy */;
+ };
+/* End PBXTargetDependency section */
+
+/* Begin XCBuildConfiguration section */
+ 63423F4E1B150A5F006CF63C /* Debug */ = {
+ isa = XCBuildConfiguration;
+ baseConfigurationReference = FF7B5489BCFE40111D768DD0 /* Pods.debug.xcconfig */;
+ buildSettings = {
+ FRAMEWORK_SEARCH_PATHS = (
+ "$(SDKROOT)/Developer/Library/Frameworks",
+ "$(inherited)",
+ );
+ GCC_PREPROCESSOR_DEFINITIONS = (
+ "DEBUG=1",
+ "$(inherited)",
+ );
+ INFOPLIST_FILE = Info.plist;
+ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ };
+ name = Debug;
+ };
+ 63423F4F1B150A5F006CF63C /* Release */ = {
+ isa = XCBuildConfiguration;
+ baseConfigurationReference = 0A4F89D9C90E9C30990218F0 /* Pods.release.xcconfig */;
+ buildSettings = {
+ FRAMEWORK_SEARCH_PATHS = (
+ "$(SDKROOT)/Developer/Library/Frameworks",
+ "$(inherited)",
+ );
+ INFOPLIST_FILE = Info.plist;
+ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ };
+ name = Release;
+ };
+ 635697D91B14FC11007A7283 /* Debug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ALWAYS_SEARCH_USER_PATHS = NO;
+ CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
+ CLANG_CXX_LIBRARY = "libc++";
+ CLANG_ENABLE_MODULES = YES;
+ CLANG_ENABLE_OBJC_ARC = YES;
+ CLANG_WARN_BOOL_CONVERSION = YES;
+ CLANG_WARN_CONSTANT_CONVERSION = YES;
+ CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
+ CLANG_WARN_EMPTY_BODY = YES;
+ CLANG_WARN_ENUM_CONVERSION = YES;
+ CLANG_WARN_INT_CONVERSION = YES;
+ CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
+ CLANG_WARN_UNREACHABLE_CODE = YES;
+ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
+ COPY_PHASE_STRIP = NO;
+ DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
+ ENABLE_STRICT_OBJC_MSGSEND = YES;
+ GCC_C_LANGUAGE_STANDARD = gnu99;
+ GCC_DYNAMIC_NO_PIC = NO;
+ GCC_NO_COMMON_BLOCKS = YES;
+ GCC_OPTIMIZATION_LEVEL = 0;
+ GCC_PREPROCESSOR_DEFINITIONS = (
+ "DEBUG=1",
+ "$(inherited)",
+ );
+ GCC_SYMBOLS_PRIVATE_EXTERN = NO;
+ GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
+ GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
+ GCC_WARN_UNDECLARED_SELECTOR = YES;
+ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
+ GCC_WARN_UNUSED_FUNCTION = YES;
+ GCC_WARN_UNUSED_VARIABLE = YES;
+ IPHONEOS_DEPLOYMENT_TARGET = 8.3;
+ MTL_ENABLE_DEBUG_INFO = YES;
+ ONLY_ACTIVE_ARCH = YES;
+ SDKROOT = iphoneos;
+ };
+ name = Debug;
+ };
+ 635697DA1B14FC11007A7283 /* Release */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ALWAYS_SEARCH_USER_PATHS = NO;
+ CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
+ CLANG_CXX_LIBRARY = "libc++";
+ CLANG_ENABLE_MODULES = YES;
+ CLANG_ENABLE_OBJC_ARC = YES;
+ CLANG_WARN_BOOL_CONVERSION = YES;
+ CLANG_WARN_CONSTANT_CONVERSION = YES;
+ CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
+ CLANG_WARN_EMPTY_BODY = YES;
+ CLANG_WARN_ENUM_CONVERSION = YES;
+ CLANG_WARN_INT_CONVERSION = YES;
+ CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
+ CLANG_WARN_UNREACHABLE_CODE = YES;
+ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
+ COPY_PHASE_STRIP = NO;
+ DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
+ ENABLE_NS_ASSERTIONS = NO;
+ ENABLE_STRICT_OBJC_MSGSEND = YES;
+ GCC_C_LANGUAGE_STANDARD = gnu99;
+ GCC_NO_COMMON_BLOCKS = YES;
+ GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
+ GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
+ GCC_WARN_UNDECLARED_SELECTOR = YES;
+ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
+ GCC_WARN_UNUSED_FUNCTION = YES;
+ GCC_WARN_UNUSED_VARIABLE = YES;
+ IPHONEOS_DEPLOYMENT_TARGET = 8.3;
+ MTL_ENABLE_DEBUG_INFO = NO;
+ SDKROOT = iphoneos;
+ VALIDATE_PRODUCT = YES;
+ };
+ name = Release;
+ };
+ 635697DC1B14FC11007A7283 /* Debug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ OTHER_LDFLAGS = "-ObjC";
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ SKIP_INSTALL = YES;
+ };
+ name = Debug;
+ };
+ 635697DD1B14FC11007A7283 /* Release */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ OTHER_LDFLAGS = "-ObjC";
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ SKIP_INSTALL = YES;
+ };
+ name = Release;
+ };
+/* End XCBuildConfiguration section */
+
+/* Begin XCConfigurationList section */
+ 63423F4D1B150A5F006CF63C /* Build configuration list for PBXNativeTarget "AllTests" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ 63423F4E1B150A5F006CF63C /* Debug */,
+ 63423F4F1B150A5F006CF63C /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
+ 635697C21B14FC11007A7283 /* Build configuration list for PBXProject "Tests" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ 635697D91B14FC11007A7283 /* Debug */,
+ 635697DA1B14FC11007A7283 /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
+ 635697DB1B14FC11007A7283 /* Build configuration list for PBXNativeTarget "Tests" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ 635697DC1B14FC11007A7283 /* Debug */,
+ 635697DD1B14FC11007A7283 /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
+/* End XCConfigurationList section */
+ };
+ rootObject = 635697BF1B14FC11007A7283 /* Project object */;
+}
diff --git a/src/objective-c/tests/Tests.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/src/objective-c/tests/Tests.xcodeproj/project.xcworkspace/contents.xcworkspacedata
new file mode 100644
index 0000000000..6c0ea84930
--- /dev/null
+++ b/src/objective-c/tests/Tests.xcodeproj/project.xcworkspace/contents.xcworkspacedata
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Workspace
+ version = "1.0">
+ <FileRef
+ location = "self:Tests.xcodeproj">
+ </FileRef>
+</Workspace>
diff --git a/src/php/bin/run_gen_code_test.sh b/src/php/bin/run_gen_code_test.sh
index 79abbe6cf8..4882a2b846 100755
--- a/src/php/bin/run_gen_code_test.sh
+++ b/src/php/bin/run_gen_code_test.sh
@@ -29,9 +29,9 @@
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
cd $(dirname $0)
-GRPC_TEST_HOST=localhost:7070 php -d extension_dir=../ext/grpc/modules/ \
+GRPC_TEST_HOST=localhost:50051 php -d extension_dir=../ext/grpc/modules/ \
-d extension=grpc.so /usr/local/bin/phpunit -v --debug --strict \
../tests/generated_code/GeneratedCodeTest.php
-GRPC_TEST_HOST=localhost:7070 php -d extension_dir=../ext/grpc/modules/ \
+GRPC_TEST_HOST=localhost:50051 php -d extension_dir=../ext/grpc/modules/ \
-d extension=grpc.so /usr/local/bin/phpunit -v --debug --strict \
../tests/generated_code/GeneratedCodeWithCallbackTest.php
diff --git a/src/python/interop/interop/_insecure_interop_test.py b/src/python/interop/interop/_insecure_interop_test.py
index 42e7a4d5c4..98ea3a6648 100644
--- a/src/python/interop/interop/_insecure_interop_test.py
+++ b/src/python/interop/interop/_insecure_interop_test.py
@@ -54,4 +54,4 @@ class InsecureInteropTest(
if __name__ == '__main__':
- unittest.main()
+ unittest.main(verbosity=2)
diff --git a/src/python/interop/interop/_interop_test_case.py b/src/python/interop/interop/_interop_test_case.py
index cd6a574e90..f40ef0ec83 100644
--- a/src/python/interop/interop/_interop_test_case.py
+++ b/src/python/interop/interop/_interop_test_case.py
@@ -53,3 +53,9 @@ class InteropTestCase(object):
def testPingPong(self):
methods.TestCase.PING_PONG.test_interoperability(self.stub, None)
+
+ def testCancelAfterBegin(self):
+ methods.TestCase.CANCEL_AFTER_BEGIN.test_interoperability(self.stub, None)
+
+ def testCancelAfterFirstResponse(self):
+ methods.TestCase.CANCEL_AFTER_FIRST_RESPONSE.test_interoperability(self.stub, None)
diff --git a/src/python/interop/interop/_secure_interop_test.py b/src/python/interop/interop/_secure_interop_test.py
index 27e76315b6..be7618f549 100644
--- a/src/python/interop/interop/_secure_interop_test.py
+++ b/src/python/interop/interop/_secure_interop_test.py
@@ -61,4 +61,4 @@ class SecureInteropTest(
if __name__ == '__main__':
- unittest.main()
+ unittest.main(verbosity=2)
diff --git a/src/python/interop/interop/methods.py b/src/python/interop/interop/methods.py
index 909b738bd1..194afadb17 100644
--- a/src/python/interop/interop/methods.py
+++ b/src/python/interop/interop/methods.py
@@ -219,6 +219,17 @@ def _server_streaming(stub):
raise ValueError(
'response body of invalid size %d!' % len(response.payload.body))
+def _cancel_after_begin(stub):
+ with stub:
+ sizes = (27182, 8, 1828, 45904)
+ payloads = [messages_pb2.Payload(body=b'\x00' * size) for size in sizes]
+ requests = [messages_pb2.StreamingInputCallRequest(payload=payload)
+ for payload in payloads]
+ responses = stub.StreamingInputCall.async(requests, _TIMEOUT)
+ responses.cancel()
+ if not responses.cancelled():
+ raise ValueError('expected call to be cancelled')
+
class _Pipe(object):
@@ -249,13 +260,18 @@ class _Pipe(object):
self._open = False
self._condition.notify()
+ def __enter__(self):
+ return self
+
+ def __exit__(self, type, value, traceback):
+ self.close()
+
def _ping_pong(stub):
request_response_sizes = (31415, 9, 2653, 58979)
request_payload_sizes = (27182, 8, 1828, 45904)
- with stub:
- pipe = _Pipe()
+ with stub, _Pipe() as pipe:
response_iterator = stub.FullDuplexCall(pipe, _TIMEOUT)
print 'Starting ping-pong with response iterator %s' % response_iterator
for response_size, payload_size in zip(
@@ -273,7 +289,33 @@ def _ping_pong(stub):
if len(response.payload.body) != response_size:
raise ValueError(
'response body of invalid size %d!' % len(response.payload.body))
- pipe.close()
+
+
+def _cancel_after_first_response(stub):
+ request_response_sizes = (31415, 9, 2653, 58979)
+ request_payload_sizes = (27182, 8, 1828, 45904)
+ with stub, _Pipe() as pipe:
+ response_iterator = stub.FullDuplexCall(pipe, _TIMEOUT)
+
+ response_size = request_response_sizes[0]
+ payload_size = request_payload_sizes[0]
+ request = messages_pb2.StreamingOutputCallRequest(
+ response_type=messages_pb2.COMPRESSABLE,
+ response_parameters=(messages_pb2.ResponseParameters(
+ size=response_size),),
+ payload=messages_pb2.Payload(body=b'\x00' * payload_size))
+ pipe.add(request)
+ response = next(response_iterator)
+ # We test the contents of `response` in the Ping Pong test - don't check
+ # them here.
+ response_iterator.cancel()
+
+ try:
+ next(response_iterator)
+ except Exception:
+ pass
+ else:
+ raise ValueError('expected call to be cancelled')
def _compute_engine_creds(stub, args):
@@ -305,6 +347,8 @@ class TestCase(enum.Enum):
SERVER_STREAMING = 'server_streaming'
CLIENT_STREAMING = 'client_streaming'
PING_PONG = 'ping_pong'
+ CANCEL_AFTER_BEGIN = 'cancel_after_begin'
+ CANCEL_AFTER_FIRST_RESPONSE = 'cancel_after_first_response'
COMPUTE_ENGINE_CREDS = 'compute_engine_creds'
SERVICE_ACCOUNT_CREDS = 'service_account_creds'
@@ -319,6 +363,10 @@ class TestCase(enum.Enum):
_client_streaming(stub)
elif self is TestCase.PING_PONG:
_ping_pong(stub)
+ elif self is TestCase.CANCEL_AFTER_BEGIN:
+ _cancel_after_begin(stub)
+ elif self is TestCase.CANCEL_AFTER_FIRST_RESPONSE:
+ _cancel_after_first_response(stub)
elif self is TestCase.COMPUTE_ENGINE_CREDS:
_compute_engine_creds(stub, args)
elif self is TestCase.SERVICE_ACCOUNT_CREDS:
diff --git a/src/python/src/grpc/_adapter/_blocking_invocation_inline_service_test.py b/src/python/src/grpc/_adapter/_blocking_invocation_inline_service_test.py
index 3cd51928d3..7a8ff0ad89 100644
--- a/src/python/src/grpc/_adapter/_blocking_invocation_inline_service_test.py
+++ b/src/python/src/grpc/_adapter/_blocking_invocation_inline_service_test.py
@@ -43,4 +43,4 @@ class BlockingInvocationInlineServiceTest(
if __name__ == '__main__':
- unittest.main()
+ unittest.main(verbosity=2)
diff --git a/src/python/src/grpc/_adapter/_c_test.py b/src/python/src/grpc/_adapter/_c_test.py
index 6e15adbda8..b06215f0e5 100644
--- a/src/python/src/grpc/_adapter/_c_test.py
+++ b/src/python/src/grpc/_adapter/_c_test.py
@@ -216,4 +216,4 @@ class _CTest(unittest.TestCase):
if __name__ == '__main__':
- unittest.main()
+ unittest.main(verbosity=2)
diff --git a/src/python/src/grpc/_adapter/_event_invocation_synchronous_event_service_test.py b/src/python/src/grpc/_adapter/_event_invocation_synchronous_event_service_test.py
index b9a13ce69f..b8ceb75d68 100644
--- a/src/python/src/grpc/_adapter/_event_invocation_synchronous_event_service_test.py
+++ b/src/python/src/grpc/_adapter/_event_invocation_synchronous_event_service_test.py
@@ -43,4 +43,4 @@ class EventInvocationSynchronousEventServiceTest(
if __name__ == '__main__':
- unittest.main()
+ unittest.main(verbosity=2)
diff --git a/src/python/src/grpc/_adapter/_future_invocation_asynchronous_event_service_test.py b/src/python/src/grpc/_adapter/_future_invocation_asynchronous_event_service_test.py
index 7d6a4ffc17..3773e65575 100644
--- a/src/python/src/grpc/_adapter/_future_invocation_asynchronous_event_service_test.py
+++ b/src/python/src/grpc/_adapter/_future_invocation_asynchronous_event_service_test.py
@@ -43,4 +43,4 @@ class FutureInvocationAsynchronousEventServiceTest(
if __name__ == '__main__':
- unittest.main()
+ unittest.main(verbosity=2)
diff --git a/src/python/src/grpc/_adapter/_links_test.py b/src/python/src/grpc/_adapter/_links_test.py
index 4fd76f60f8..50257d8691 100644
--- a/src/python/src/grpc/_adapter/_links_test.py
+++ b/src/python/src/grpc/_adapter/_links_test.py
@@ -274,4 +274,4 @@ class RoundTripTest(unittest.TestCase):
if __name__ == '__main__':
- unittest.main()
+ unittest.main(verbosity=2)
diff --git a/src/python/src/grpc/_adapter/_lonely_rear_link_test.py b/src/python/src/grpc/_adapter/_lonely_rear_link_test.py
index bdb1ee2379..7f5021f40e 100644
--- a/src/python/src/grpc/_adapter/_lonely_rear_link_test.py
+++ b/src/python/src/grpc/_adapter/_lonely_rear_link_test.py
@@ -97,4 +97,4 @@ class LonelyRearLinkTest(unittest.TestCase):
if __name__ == '__main__':
- unittest.main()
+ unittest.main(verbosity=2)
diff --git a/src/python/src/grpc/_adapter/_low_test.py b/src/python/src/grpc/_adapter/_low_test.py
index 09c4660a2b..d4b628c2ae 100644
--- a/src/python/src/grpc/_adapter/_low_test.py
+++ b/src/python/src/grpc/_adapter/_low_test.py
@@ -412,4 +412,4 @@ class ExpirationTest(unittest.TestCase):
if __name__ == '__main__':
- unittest.main()
+ unittest.main(verbosity=2)
diff --git a/src/python/src/grpc/early_adopter/implementations_test.py b/src/python/src/grpc/early_adopter/implementations_test.py
index 32b974724c..49f0e949c4 100644
--- a/src/python/src/grpc/early_adopter/implementations_test.py
+++ b/src/python/src/grpc/early_adopter/implementations_test.py
@@ -177,4 +177,4 @@ class EarlyAdopterImplementationsTest(unittest.TestCase):
if __name__ == '__main__':
- unittest.main()
+ unittest.main(verbosity=2)
diff --git a/src/python/src/grpc/framework/base/implementations_test.py b/src/python/src/grpc/framework/base/implementations_test.py
index d40bb4d92e..72087f4456 100644
--- a/src/python/src/grpc/framework/base/implementations_test.py
+++ b/src/python/src/grpc/framework/base/implementations_test.py
@@ -77,4 +77,4 @@ class ImplementationsTest(
if __name__ == '__main__':
- unittest.main()
+ unittest.main(verbosity=2)
diff --git a/src/python/src/grpc/framework/face/blocking_invocation_inline_service_test.py b/src/python/src/grpc/framework/face/blocking_invocation_inline_service_test.py
index 636cd701ff..763f0f0edc 100644
--- a/src/python/src/grpc/framework/face/blocking_invocation_inline_service_test.py
+++ b/src/python/src/grpc/framework/face/blocking_invocation_inline_service_test.py
@@ -43,4 +43,4 @@ class BlockingInvocationInlineServiceTest(
if __name__ == '__main__':
- unittest.main()
+ unittest.main(verbosity=2)
diff --git a/src/python/src/grpc/framework/face/event_invocation_synchronous_event_service_test.py b/src/python/src/grpc/framework/face/event_invocation_synchronous_event_service_test.py
index 25f3e297b5..e1ab3cf711 100644
--- a/src/python/src/grpc/framework/face/event_invocation_synchronous_event_service_test.py
+++ b/src/python/src/grpc/framework/face/event_invocation_synchronous_event_service_test.py
@@ -43,4 +43,4 @@ class EventInvocationSynchronousEventServiceTest(
if __name__ == '__main__':
- unittest.main()
+ unittest.main(verbosity=2)
diff --git a/src/python/src/grpc/framework/face/future_invocation_asynchronous_event_service_test.py b/src/python/src/grpc/framework/face/future_invocation_asynchronous_event_service_test.py
index 38229ea9f4..2d13bb911d 100644
--- a/src/python/src/grpc/framework/face/future_invocation_asynchronous_event_service_test.py
+++ b/src/python/src/grpc/framework/face/future_invocation_asynchronous_event_service_test.py
@@ -43,4 +43,4 @@ class FutureInvocationAsynchronousEventServiceTest(
if __name__ == '__main__':
- unittest.main()
+ unittest.main(verbosity=2)
diff --git a/src/python/src/grpc/framework/foundation/_later_test.py b/src/python/src/grpc/framework/foundation/_later_test.py
index e83e703128..6c2459e185 100644
--- a/src/python/src/grpc/framework/foundation/_later_test.py
+++ b/src/python/src/grpc/framework/foundation/_later_test.py
@@ -148,4 +148,4 @@ class LaterTest(unittest.TestCase):
self.assertEqual(return_value, future_passed_to_callback_cell[0].result())
if __name__ == '__main__':
- unittest.main()
+ unittest.main(verbosity=2)
diff --git a/src/python/src/grpc/framework/foundation/_logging_pool_test.py b/src/python/src/grpc/framework/foundation/_logging_pool_test.py
index c92cf8c0ab..452802da6a 100644
--- a/src/python/src/grpc/framework/foundation/_logging_pool_test.py
+++ b/src/python/src/grpc/framework/foundation/_logging_pool_test.py
@@ -61,4 +61,4 @@ class LoggingPoolTest(unittest.TestCase):
if __name__ == '__main__':
- unittest.main()
+ unittest.main(verbosity=2)
diff --git a/src/ruby/bin/interop/interop_server.rb b/src/ruby/bin/interop/interop_server.rb
index 78cb8dd836..2ba8d2c19e 100755
--- a/src/ruby/bin/interop/interop_server.rb
+++ b/src/ruby/bin/interop/interop_server.rb
@@ -128,16 +128,19 @@ class TestTarget < Grpc::Testing::TestService::Service
cls = StreamingOutputCallResponse
Thread.new do
begin
+ GRPC.logger.info('interop-server: started receiving')
reqs.each do |req|
- GRPC.logger.info("read #{req.inspect}")
resp_size = req.response_parameters[0].size
+ GRPC.logger.info("read a req, response size is #{resp_size}")
resp = cls.new(payload: Payload.new(type: req.response_type,
body: nulls(resp_size)))
q.push(resp)
end
- GRPC.logger.info('finished reads')
+ GRPC.logger.info('interop-server: finished receiving')
q.push(self)
rescue StandardError => e
+ GRPC.logger.info('interop-server: failed')
+ GRPC.logger.warn(e)
q.push(e) # share the exception with the enumerator
end
end
diff --git a/src/ruby/lib/grpc/generic/active_call.rb b/src/ruby/lib/grpc/generic/active_call.rb
index 5f7beb5ab1..04abab8ac3 100644
--- a/src/ruby/lib/grpc/generic/active_call.rb
+++ b/src/ruby/lib/grpc/generic/active_call.rb
@@ -39,6 +39,7 @@ class Struct
return nil if status.nil?
fail GRPC::Cancelled if status.code == GRPC::Core::StatusCodes::CANCELLED
if status.code != GRPC::Core::StatusCodes::OK
+ GRPC.logger.debug("Failing with status #{status}")
# raise BadStatus, propagating the metadata if present.
md = status.metadata
with_sym_keys = Hash[md.each_pair.collect { |x, y| [x.to_sym, y] }]
diff --git a/src/ruby/lib/grpc/generic/bidi_call.rb b/src/ruby/lib/grpc/generic/bidi_call.rb
index 67143d40cf..f1b9f6b00d 100644
--- a/src/ruby/lib/grpc/generic/bidi_call.rb
+++ b/src/ruby/lib/grpc/generic/bidi_call.rb
@@ -100,6 +100,7 @@ module GRPC
replys = gen_each_reply.call(each_queued_msg)
@enq_th = start_write_loop(replys, is_client: false)
@loop_th = start_read_loop
+ @enq_th.join if @enq_th.alive?
end
private
@@ -115,7 +116,7 @@ module GRPC
return enum_for(:each_queued_msg) unless block_given?
count = 0
loop do
- GRPC.logger.debug("each_queued_msg: msg##{count}")
+ GRPC.logger.debug("each_queued_msg: waiting##{count}")
count += 1
req = @readq.pop
GRPC.logger.debug("each_queued_msg: req = #{req}")
@@ -123,70 +124,73 @@ module GRPC
break if req.equal?(END_OF_READS)
yield req
end
- @enq_th.join if @enq_th.alive?
end
# during bidi-streaming, read the requests to send from a separate thread
# read so that read_loop does not block waiting for requests to read.
def start_write_loop(requests, is_client: true)
Thread.new do # TODO: run on a thread pool
- write_tag = Object.new
+ GRPC.logger.debug('bidi-write-loop: starting')
begin
+ write_tag = Object.new
count = 0
requests.each do |req|
- GRPC.logger.debug("bidi-write_loop: #{count}")
+ GRPC.logger.debug("bidi-write-loop: #{count}")
count += 1
payload = @marshal.call(req)
@call.run_batch(@cq, write_tag, INFINITE_FUTURE,
SEND_MESSAGE => payload)
end
+ GRPC.logger.debug("bidi-write-loop: #{count} writes done")
if is_client
- GRPC.logger.debug("bidi-write-loop: sent #{count}, waiting")
+ GRPC.logger.debug("bidi-write-loop: client sent #{count}, waiting")
+ @call.run_batch(@cq, write_tag, INFINITE_FUTURE,
+ SEND_CLOSE_FROM_CLIENT => nil)
batch_result = @call.run_batch(@cq, write_tag, INFINITE_FUTURE,
- SEND_CLOSE_FROM_CLIENT => nil,
RECV_STATUS_ON_CLIENT => nil)
batch_result.check_status
end
rescue StandardError => e
- GRPC.logger.warn('bidi-write_loop: failed')
+ GRPC.logger.warn('bidi-write-loop: failed')
GRPC.logger.warn(e)
raise e
end
+ GRPC.logger.debug('bidi-write-loop: finished')
end
end
# starts the read loop
def start_read_loop
Thread.new do
+ GRPC.logger.debug('bidi-read-loop: starting')
begin
read_tag = Object.new
count = 0
-
# queue the initial read before beginning the loop
loop do
- GRPC.logger.debug("bidi-read_loop: #{count}")
+ GRPC.logger.debug("bidi-read-loop: #{count}")
count += 1
# TODO: ensure metadata is read if available, currently it's not
batch_result = @call.run_batch(@cq, read_tag, INFINITE_FUTURE,
RECV_MESSAGE => nil)
# handle the next message
if batch_result.message.nil?
+ GRPC.logger.debug("bidi-read-loop: null batch #{batch_result}")
@readq.push(END_OF_READS)
GRPC.logger.debug('bidi-read-loop: done reading!')
break
end
# push the latest read onto the queue and continue reading
- GRPC.logger.debug("received req: #{batch_result.message}")
res = @unmarshal.call(batch_result.message)
@readq.push(res)
end
-
rescue StandardError => e
- GRPC.logger.warn('bidi: read_loop failed')
+ GRPC.logger.warn('bidi: read-loop failed')
GRPC.logger.warn(e)
@readq.push(e) # let each_queued_msg terminate with this error
end
+ GRPC.logger.debug('bidi-read-loop: finished')
end
end
end
diff --git a/src/ruby/lib/grpc/generic/rpc_desc.rb b/src/ruby/lib/grpc/generic/rpc_desc.rb
index 2fd61c5f7e..dd90d8d91d 100644
--- a/src/ruby/lib/grpc/generic/rpc_desc.rb
+++ b/src/ruby/lib/grpc/generic/rpc_desc.rb
@@ -137,6 +137,7 @@ module GRPC
def send_status(active_client, code, details, **kw)
details = 'Not sure why' if details.nil?
+ GRPC.logger.debug("Sending status #{code}:#{details}")
active_client.send_status(code, details, code == OK, **kw)
rescue StandardError => e
GRPC.logger.warn("Could not send status #{code}:#{details}")