aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar Craig Tiller <ctiller@google.com>2015-08-04 08:23:32 -0700
committerGravatar Craig Tiller <ctiller@google.com>2015-08-04 08:23:32 -0700
commita9c643fc602bda93d373694661e7e1f8f1ec72ac (patch)
tree9cba5821eed929ff33b7585adec65dd59524a64e /src
parent9c7c0e8cbd5d43a99fb57530eab1e9bf2a37ef81 (diff)
parent98dd83ec4e8fa87875df82ca406a43e12ed06b6c (diff)
Merge github.com:grpc/grpc into plucking-hell
Diffstat (limited to 'src')
-rw-r--r--src/compiler/generator_helpers.h8
-rw-r--r--src/core/iomgr/fd_posix.c6
-rw-r--r--src/core/iomgr/tcp_windows.c6
-rw-r--r--src/core/surface/channel_connectivity.c8
-rw-r--r--src/core/transport/chttp2/alpn.c3
-rw-r--r--src/cpp/client/client_context.cc11
-rw-r--r--src/cpp/server/server_context.cc11
-rw-r--r--src/node/examples/math_server.js2
-rw-r--r--src/node/examples/route_guide_server.js2
-rw-r--r--src/node/examples/stock_server.js2
-rw-r--r--src/node/ext/server.cc44
-rw-r--r--src/node/ext/server.h1
-rw-r--r--src/node/ext/server_credentials.cc18
-rw-r--r--src/node/ext/server_credentials.h1
-rw-r--r--src/node/interop/interop_server.js4
-rw-r--r--src/node/src/server.js6
-rw-r--r--src/node/test/call_test.js3
-rw-r--r--src/node/test/end_to_end_test.js3
-rw-r--r--src/node/test/health_test.js3
-rw-r--r--src/node/test/math_client_test.js3
-rw-r--r--src/node/test/server_test.js19
-rw-r--r--src/node/test/surface_test.js12
-rw-r--r--src/objective-c/GRPCClient/GRPCCall.m14
-rw-r--r--src/objective-c/GRPCClient/private/GRPCCompletionQueue.h18
-rw-r--r--src/objective-c/generated_libraries/RemoteTestClient/RemoteTest.podspec5
-rw-r--r--src/objective-c/generated_libraries/RouteGuideClient/RouteGuide.podspec5
-rwxr-xr-xsrc/objective-c/tests/build_tests.sh37
-rwxr-xr-xsrc/objective-c/tests/run_tests.sh3
28 files changed, 156 insertions, 102 deletions
diff --git a/src/compiler/generator_helpers.h b/src/compiler/generator_helpers.h
index 7bdaff1c9b..68b807b057 100644
--- a/src/compiler/generator_helpers.h
+++ b/src/compiler/generator_helpers.h
@@ -126,7 +126,13 @@ inline grpc::string LowerUnderscoreToUpperCamel(grpc::string str) {
}
inline grpc::string FileNameInUpperCamel(const grpc::protobuf::FileDescriptor *file) {
- return LowerUnderscoreToUpperCamel(StripProto(file->name()));
+ std::vector<grpc::string> tokens = tokenize(StripProto(file->name()), "/");
+ grpc::string result = "";
+ for (unsigned int i = 0; i < tokens.size() - 1; i++) {
+ result += tokens[i] + "/";
+ }
+ result += LowerUnderscoreToUpperCamel(tokens.back());
+ return result;
}
enum MethodType {
diff --git a/src/core/iomgr/fd_posix.c b/src/core/iomgr/fd_posix.c
index 4fb6b46ea6..2d08a77a70 100644
--- a/src/core/iomgr/fd_posix.c
+++ b/src/core/iomgr/fd_posix.c
@@ -382,13 +382,15 @@ gpr_uint32 grpc_fd_begin_poll(grpc_fd *fd, grpc_pollset *pollset,
return 0;
}
/* if there is nobody polling for read, but we need to, then start doing so */
- if (read_mask && !fd->read_watcher && gpr_atm_acq_load(&fd->readst) > READY) {
+ if (read_mask && !fd->read_watcher &&
+ (gpr_uintptr)gpr_atm_acq_load(&fd->readst) > READY) {
fd->read_watcher = watcher;
mask |= read_mask;
}
/* if there is nobody polling for write, but we need to, then start doing so
*/
- if (write_mask && !fd->write_watcher && gpr_atm_acq_load(&fd->writest) > READY) {
+ if (write_mask && !fd->write_watcher &&
+ (gpr_uintptr)gpr_atm_acq_load(&fd->writest) > READY) {
fd->write_watcher = watcher;
mask |= write_mask;
}
diff --git a/src/core/iomgr/tcp_windows.c b/src/core/iomgr/tcp_windows.c
index 5e0457a37b..89aa741470 100644
--- a/src/core/iomgr/tcp_windows.c
+++ b/src/core/iomgr/tcp_windows.c
@@ -369,14 +369,16 @@ static grpc_endpoint_write_status win_write(grpc_endpoint *ep,
}
static void win_add_to_pollset(grpc_endpoint *ep, grpc_pollset *ps) {
+ grpc_tcp *tcp;
(void) ps;
- grpc_tcp *tcp = (grpc_tcp *) ep;
+ tcp = (grpc_tcp *) ep;
grpc_iocp_add_socket(tcp->socket);
}
static void win_add_to_pollset_set(grpc_endpoint *ep, grpc_pollset_set *pss) {
+ grpc_tcp *tcp;
(void) pss;
- grpc_tcp *tcp = (grpc_tcp *) ep;
+ tcp = (grpc_tcp *) ep;
grpc_iocp_add_socket(tcp->socket);
}
diff --git a/src/core/surface/channel_connectivity.c b/src/core/surface/channel_connectivity.c
index b6ea86d730..1223706457 100644
--- a/src/core/surface/channel_connectivity.c
+++ b/src/core/surface/channel_connectivity.c
@@ -70,7 +70,6 @@ typedef struct {
grpc_iomgr_closure on_complete;
grpc_alarm alarm;
grpc_connectivity_state state;
- grpc_connectivity_state *optional_new_state;
grpc_completion_queue *cq;
grpc_cq_completion completion_storage;
grpc_channel *channel;
@@ -124,9 +123,6 @@ static void partly_done(state_watcher *w, int due_to_completion) {
switch (w->phase) {
case WAITING:
w->phase = CALLING_BACK;
- if (w->optional_new_state) {
- *w->optional_new_state = w->state;
- }
grpc_cq_end_op(w->cq, w->tag, w->success, finished_completion, w,
&w->completion_storage);
break;
@@ -154,8 +150,7 @@ static void timeout_complete(void *pw, int success) { partly_done(pw, 0); }
void grpc_channel_watch_connectivity_state(
grpc_channel *channel, grpc_connectivity_state last_observed_state,
- grpc_connectivity_state *optional_new_state, gpr_timespec deadline,
- grpc_completion_queue *cq, void *tag) {
+ gpr_timespec deadline, grpc_completion_queue *cq, void *tag) {
grpc_channel_element *client_channel_elem =
grpc_channel_stack_last_element(grpc_channel_get_channel_stack(channel));
state_watcher *w = gpr_malloc(sizeof(*w));
@@ -167,7 +162,6 @@ void grpc_channel_watch_connectivity_state(
w->phase = WAITING;
w->state = last_observed_state;
w->success = 0;
- w->optional_new_state = optional_new_state;
w->cq = cq;
w->tag = tag;
w->channel = channel;
diff --git a/src/core/transport/chttp2/alpn.c b/src/core/transport/chttp2/alpn.c
index 3ccd5796ba..69da4e6718 100644
--- a/src/core/transport/chttp2/alpn.c
+++ b/src/core/transport/chttp2/alpn.c
@@ -36,8 +36,7 @@
#include <grpc/support/useful.h>
/* in order of preference */
-static const char *const supported_versions[] = {"h2", "h2-17", "h2-16",
- "h2-15", "h2-14"};
+static const char *const supported_versions[] = {"h2"};
int grpc_chttp2_is_alpn_version_supported(const char *version, size_t size) {
size_t i;
diff --git a/src/cpp/client/client_context.cc b/src/cpp/client/client_context.cc
index 14ab772e50..c38d0c1df6 100644
--- a/src/cpp/client/client_context.cc
+++ b/src/cpp/client/client_context.cc
@@ -34,6 +34,7 @@
#include <grpc++/client_context.h>
#include <grpc/grpc.h>
+#include <grpc/support/alloc.h>
#include <grpc/support/string_util.h>
#include <grpc++/credentials.h>
#include <grpc++/time.h>
@@ -104,4 +105,14 @@ void ClientContext::TryCancel() {
}
}
+grpc::string ClientContext::peer() const {
+ grpc::string peer;
+ if (call_) {
+ char* c_peer = grpc_call_get_peer(call_);
+ peer = c_peer;
+ gpr_free(c_peer);
+ }
+ return peer;
+}
+
} // namespace grpc
diff --git a/src/cpp/server/server_context.cc b/src/cpp/server/server_context.cc
index f6c073040b..cf19556e7a 100644
--- a/src/cpp/server/server_context.cc
+++ b/src/cpp/server/server_context.cc
@@ -34,6 +34,7 @@
#include <grpc++/server_context.h>
#include <grpc/grpc.h>
+#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc++/impl/call.h>
#include <grpc++/impl/sync.h>
@@ -179,6 +180,16 @@ std::shared_ptr<const AuthContext> ServerContext::auth_context() const {
return auth_context_;
}
+grpc::string ServerContext::peer() const {
+ grpc::string peer;
+ if (call_) {
+ char* c_peer = grpc_call_get_peer(call_);
+ peer = c_peer;
+ gpr_free(c_peer);
+ }
+ return peer;
+}
+
const struct census_context* ServerContext::census_context() const {
return grpc_census_call_get_context(call_);
}
diff --git a/src/node/examples/math_server.js b/src/node/examples/math_server.js
index b1f8a6323f..31892c65df 100644
--- a/src/node/examples/math_server.js
+++ b/src/node/examples/math_server.js
@@ -115,7 +115,7 @@ server.addProtoService(math.Math.service, {
});
if (require.main === module) {
- server.bind('0.0.0.0:50051');
+ server.bind('0.0.0.0:50051', grpc.ServerCredentials.createInsecure());
server.start();
}
diff --git a/src/node/examples/route_guide_server.js b/src/node/examples/route_guide_server.js
index 70044a322c..bb8e79b5bd 100644
--- a/src/node/examples/route_guide_server.js
+++ b/src/node/examples/route_guide_server.js
@@ -239,7 +239,7 @@ function getServer() {
if (require.main === module) {
// If this is run as a script, start a server on an unused port
var routeServer = getServer();
- routeServer.bind('0.0.0.0:50051');
+ routeServer.bind('0.0.0.0:50051', grpc.ServerCredentials.createInsecure());
var argv = parseArgs(process.argv, {
string: 'db_path'
});
diff --git a/src/node/examples/stock_server.js b/src/node/examples/stock_server.js
index f2eb6ad4ab..dfcfe30eb4 100644
--- a/src/node/examples/stock_server.js
+++ b/src/node/examples/stock_server.js
@@ -80,7 +80,7 @@ stockServer.addProtoService(examples.Stock.service, {
});
if (require.main === module) {
- stockServer.bind('0.0.0.0:50051');
+ stockServer.bind('0.0.0.0:50051', grpc.ServerCredentials.createInsecure());
stockServer.listen();
}
diff --git a/src/node/ext/server.cc b/src/node/ext/server.cc
index 8554fce777..04fabc871d 100644
--- a/src/node/ext/server.cc
+++ b/src/node/ext/server.cc
@@ -136,10 +136,6 @@ void Server::Init(Handle<Object> exports) {
tpl, "addHttp2Port",
NanNew<FunctionTemplate>(AddHttp2Port)->GetFunction());
- NanSetPrototypeTemplate(
- tpl, "addSecureHttp2Port",
- NanNew<FunctionTemplate>(AddSecureHttp2Port)->GetFunction());
-
NanSetPrototypeTemplate(tpl, "start",
NanNew<FunctionTemplate>(Start)->GetFunction());
@@ -248,43 +244,35 @@ NAN_METHOD(Server::RequestCall) {
NAN_METHOD(Server::AddHttp2Port) {
NanScope();
if (!HasInstance(args.This())) {
- return NanThrowTypeError("addHttp2Port can only be called on a Server");
- }
- if (!args[0]->IsString()) {
- return NanThrowTypeError("addHttp2Port's argument must be a String");
- }
- Server *server = ObjectWrap::Unwrap<Server>(args.This());
- if (server->wrapped_server == NULL) {
- return NanThrowError("addHttp2Port cannot be called on a shut down Server");
- }
- NanReturnValue(NanNew<Number>(grpc_server_add_http2_port(
- server->wrapped_server, *NanUtf8String(args[0]))));
-}
-
-NAN_METHOD(Server::AddSecureHttp2Port) {
- NanScope();
- if (!HasInstance(args.This())) {
return NanThrowTypeError(
- "addSecureHttp2Port can only be called on a Server");
+ "addHttp2Port can only be called on a Server");
}
if (!args[0]->IsString()) {
return NanThrowTypeError(
- "addSecureHttp2Port's first argument must be a String");
+ "addHttp2Port's first argument must be a String");
}
if (!ServerCredentials::HasInstance(args[1])) {
return NanThrowTypeError(
- "addSecureHttp2Port's second argument must be ServerCredentials");
+ "addHttp2Port's second argument must be ServerCredentials");
}
Server *server = ObjectWrap::Unwrap<Server>(args.This());
if (server->wrapped_server == NULL) {
return NanThrowError(
- "addSecureHttp2Port cannot be called on a shut down Server");
+ "addHttp2Port cannot be called on a shut down Server");
}
- ServerCredentials *creds = ObjectWrap::Unwrap<ServerCredentials>(
+ ServerCredentials *creds_object = ObjectWrap::Unwrap<ServerCredentials>(
args[1]->ToObject());
- NanReturnValue(NanNew<Number>(grpc_server_add_secure_http2_port(
- server->wrapped_server, *NanUtf8String(args[0]),
- creds->GetWrappedServerCredentials())));
+ grpc_server_credentials *creds = creds_object->GetWrappedServerCredentials();
+ int port;
+ if (creds == NULL) {
+ port = grpc_server_add_http2_port(server->wrapped_server,
+ *NanUtf8String(args[0]));
+ } else {
+ port = grpc_server_add_secure_http2_port(server->wrapped_server,
+ *NanUtf8String(args[0]),
+ creds);
+ }
+ NanReturnValue(NanNew<Number>(port));
}
NAN_METHOD(Server::Start) {
diff --git a/src/node/ext/server.h b/src/node/ext/server.h
index 5b4b18a0e0..faab7e3418 100644
--- a/src/node/ext/server.h
+++ b/src/node/ext/server.h
@@ -66,7 +66,6 @@ class Server : public ::node::ObjectWrap {
static NAN_METHOD(New);
static NAN_METHOD(RequestCall);
static NAN_METHOD(AddHttp2Port);
- static NAN_METHOD(AddSecureHttp2Port);
static NAN_METHOD(Start);
static NAN_METHOD(Shutdown);
static NanCallback *constructor;
diff --git a/src/node/ext/server_credentials.cc b/src/node/ext/server_credentials.cc
index c4a93a6465..1b8e7b43fb 100644
--- a/src/node/ext/server_credentials.cc
+++ b/src/node/ext/server_credentials.cc
@@ -73,6 +73,8 @@ void ServerCredentials::Init(Handle<Object> exports) {
Handle<Function> ctr = tpl->GetFunction();
ctr->Set(NanNew("createSsl"),
NanNew<FunctionTemplate>(CreateSsl)->GetFunction());
+ ctr->Set(NanNew("createInsecure"),
+ NanNew<FunctionTemplate>(CreateInsecure)->GetFunction());
constructor = new NanCallback(ctr);
exports->Set(NanNew("ServerCredentials"), ctr);
}
@@ -85,9 +87,6 @@ bool ServerCredentials::HasInstance(Handle<Value> val) {
Handle<Value> ServerCredentials::WrapStruct(
grpc_server_credentials *credentials) {
NanEscapableScope();
- if (credentials == NULL) {
- return NanEscapeScope(NanNull());
- }
const int argc = 1;
Handle<Value> argv[argc] = {
NanNew<External>(reinterpret_cast<void *>(credentials))};
@@ -140,8 +139,17 @@ NAN_METHOD(ServerCredentials::CreateSsl) {
key_cert_pair.cert_chain = ::node::Buffer::Data(args[2]);
// TODO Add a force_client_auth parameter and pass it as the last parameter
// here.
- NanReturnValue(WrapStruct(
- grpc_ssl_server_credentials_create(root_certs, &key_cert_pair, 1, 0)));
+ grpc_server_credentials *creds =
+ grpc_ssl_server_credentials_create(root_certs, &key_cert_pair, 1, 0);
+ if (creds == NULL) {
+ NanReturnNull();
+ }
+ NanReturnValue(WrapStruct(creds));
+}
+
+NAN_METHOD(ServerCredentials::CreateInsecure) {
+ NanScope();
+ NanReturnValue(WrapStruct(NULL));
}
} // namespace node
diff --git a/src/node/ext/server_credentials.h b/src/node/ext/server_credentials.h
index 80747504a1..63903f663c 100644
--- a/src/node/ext/server_credentials.h
+++ b/src/node/ext/server_credentials.h
@@ -63,6 +63,7 @@ class ServerCredentials : public ::node::ObjectWrap {
static NAN_METHOD(New);
static NAN_METHOD(CreateSsl);
+ static NAN_METHOD(CreateInsecure);
static NanCallback *constructor;
// Used for typechecking instances of this javascript class
static v8::Persistent<v8::FunctionTemplate> fun_tpl;
diff --git a/src/node/interop/interop_server.js b/src/node/interop/interop_server.js
index 505c6bb537..ece22cce31 100644
--- a/src/node/interop/interop_server.js
+++ b/src/node/interop/interop_server.js
@@ -161,7 +161,7 @@ function handleHalfDuplex(call) {
function getServer(port, tls) {
// TODO(mlumish): enable TLS functionality
var options = {};
- var server_creds = null;
+ var server_creds;
if (tls) {
var key_path = path.join(__dirname, '../test/data/server1.key');
var pem_path = path.join(__dirname, '../test/data/server1.pem');
@@ -171,6 +171,8 @@ function getServer(port, tls) {
server_creds = grpc.ServerCredentials.createSsl(null,
key_data,
pem_data);
+ } else {
+ server_creds = grpc.ServerCredentials.createInsecure();
}
var server = new grpc.Server(options);
server.addProtoService(testProto.TestService.service, {
diff --git a/src/node/src/server.js b/src/node/src/server.js
index 9fbd1ee3bd..5c62f5990c 100644
--- a/src/node/src/server.js
+++ b/src/node/src/server.js
@@ -714,11 +714,7 @@ Server.prototype.bind = function(port, creds) {
if (this.started) {
throw new Error('Can\'t bind an already running server to an address');
}
- if (creds) {
- return this._server.addSecureHttp2Port(port, creds);
- } else {
- return this._server.addHttp2Port(port);
- }
+ return this._server.addHttp2Port(port, creds);
};
/**
diff --git a/src/node/test/call_test.js b/src/node/test/call_test.js
index c5edab8bcd..48d859a8ec 100644
--- a/src/node/test/call_test.js
+++ b/src/node/test/call_test.js
@@ -55,7 +55,8 @@ describe('call', function() {
var server;
before(function() {
server = new grpc.Server();
- var port = server.addHttp2Port('localhost:0');
+ var port = server.addHttp2Port('localhost:0',
+ grpc.ServerCredentials.createInsecure());
server.start();
channel = new grpc.Channel('localhost:' + port, insecureCreds);
});
diff --git a/src/node/test/end_to_end_test.js b/src/node/test/end_to_end_test.js
index 9133ceca92..ea41dfc28c 100644
--- a/src/node/test/end_to_end_test.js
+++ b/src/node/test/end_to_end_test.js
@@ -64,7 +64,8 @@ describe('end-to-end', function() {
var channel;
before(function() {
server = new grpc.Server();
- var port_num = server.addHttp2Port('0.0.0.0:0');
+ var port_num = server.addHttp2Port('0.0.0.0:0',
+ grpc.ServerCredentials.createInsecure());
server.start();
channel = new grpc.Channel('localhost:' + port_num, insecureCreds);
});
diff --git a/src/node/test/health_test.js b/src/node/test/health_test.js
index 93b068be31..be4ef1d251 100644
--- a/src/node/test/health_test.js
+++ b/src/node/test/health_test.js
@@ -54,7 +54,8 @@ describe('Health Checking', function() {
new health.Implementation(statusMap));
var healthClient;
before(function() {
- var port_num = healthServer.bind('0.0.0.0:0');
+ var port_num = healthServer.bind('0.0.0.0:0',
+ grpc.ServerCredentials.createInsecure());
healthServer.start();
healthClient = new health.Client('localhost:' + port_num,
grpc.Credentials.createInsecure());
diff --git a/src/node/test/math_client_test.js b/src/node/test/math_client_test.js
index 1bd85ca495..ef01870a4c 100644
--- a/src/node/test/math_client_test.js
+++ b/src/node/test/math_client_test.js
@@ -51,7 +51,8 @@ var server = require('../examples/math_server.js');
describe('Math client', function() {
before(function(done) {
- var port_num = server.bind('0.0.0.0:0');
+ var port_num = server.bind('0.0.0.0:0',
+ grpc.ServerCredentials.createInsecure());
server.start();
math_client = new math.Math('localhost:' + port_num,
grpc.Credentials.createInsecure());
diff --git a/src/node/test/server_test.js b/src/node/test/server_test.js
index 9c7bb465aa..a9df43909e 100644
--- a/src/node/test/server_test.js
+++ b/src/node/test/server_test.js
@@ -59,16 +59,11 @@ describe('server', function() {
it('should bind to an unused port', function() {
var port;
assert.doesNotThrow(function() {
- port = server.addHttp2Port('0.0.0.0:0');
+ port = server.addHttp2Port('0.0.0.0:0',
+ grpc.ServerCredentials.createInsecure());
});
assert(port > 0);
});
- });
- describe('addSecureHttp2Port', function() {
- var server;
- before(function() {
- server = new grpc.Server();
- });
it('should bind to an unused port with ssl credentials', function() {
var port;
var key_path = path.join(__dirname, '../test/data/server1.key');
@@ -77,16 +72,22 @@ describe('server', function() {
var pem_data = fs.readFileSync(pem_path);
var creds = grpc.ServerCredentials.createSsl(null, key_data, pem_data);
assert.doesNotThrow(function() {
- port = server.addSecureHttp2Port('0.0.0.0:0', creds);
+ port = server.addHttp2Port('0.0.0.0:0', creds);
});
assert(port > 0);
});
});
+ describe('addSecureHttp2Port', function() {
+ var server;
+ before(function() {
+ server = new grpc.Server();
+ });
+ });
describe('listen', function() {
var server;
before(function() {
server = new grpc.Server();
- server.addHttp2Port('0.0.0.0:0');
+ server.addHttp2Port('0.0.0.0:0', grpc.ServerCredentials.createInsecure());
});
after(function() {
server.shutdown();
diff --git a/src/node/test/surface_test.js b/src/node/test/surface_test.js
index 18c99a5994..dda2f8d127 100644
--- a/src/node/test/surface_test.js
+++ b/src/node/test/surface_test.js
@@ -47,6 +47,8 @@ var mathService = math_proto.lookup('math.Math');
var _ = require('lodash');
+var server_insecure_creds = grpc.ServerCredentials.createInsecure();
+
describe('File loader', function() {
it('Should load a proto file by default', function() {
assert.doesNotThrow(function() {
@@ -122,7 +124,7 @@ describe('Echo service', function() {
callback(null, call.request);
}
});
- var port = server.bind('localhost:0');
+ var port = server.bind('localhost:0', server_insecure_creds);
var Client = surface_client.makeProtobufClientConstructor(echo_service);
client = new Client('localhost:' + port, grpc.Credentials.createInsecure());
server.start();
@@ -166,7 +168,7 @@ describe('Generic client and server', function() {
callback(null, _.capitalize(call.request));
}
});
- var port = server.bind('localhost:0');
+ var port = server.bind('localhost:0', server_insecure_creds);
server.start();
var Client = grpc.makeGenericClientConstructor(string_service_attrs);
client = new Client('localhost:' + port,
@@ -215,7 +217,7 @@ describe('Echo metadata', function() {
});
}
});
- var port = server.bind('localhost:0');
+ var port = server.bind('localhost:0', server_insecure_creds);
var Client = surface_client.makeProtobufClientConstructor(test_service);
client = new Client('localhost:' + port, grpc.Credentials.createInsecure());
server.start();
@@ -336,7 +338,7 @@ describe('Other conditions', function() {
});
}
});
- port = server.bind('localhost:0');
+ port = server.bind('localhost:0', server_insecure_creds);
var Client = surface_client.makeProtobufClientConstructor(test_service);
client = new Client('localhost:' + port, grpc.Credentials.createInsecure());
server.start();
@@ -602,7 +604,7 @@ describe('Cancelling surface client', function() {
'fib': function(stream) {},
'sum': function(stream) {}
});
- var port = server.bind('localhost:0');
+ var port = server.bind('localhost:0', server_insecure_creds);
var Client = surface_client.makeProtobufClientConstructor(mathService);
client = new Client('localhost:' + port, grpc.Credentials.createInsecure());
server.start();
diff --git a/src/objective-c/GRPCClient/GRPCCall.m b/src/objective-c/GRPCClient/GRPCCall.m
index 9435bf2b35..9d9648ae28 100644
--- a/src/objective-c/GRPCClient/GRPCCall.m
+++ b/src/objective-c/GRPCClient/GRPCCall.m
@@ -38,7 +38,6 @@
#import <RxLibrary/GRXConcurrentWriteable.h>
#import "private/GRPCChannel.h"
-#import "private/GRPCCompletionQueue.h"
#import "private/GRPCWrappedCall.h"
#import "private/NSData+GRPC.h"
#import "private/NSDictionary+GRPC.h"
@@ -72,7 +71,6 @@ NSString * const kGRPCStatusMetadataKey = @"io.grpc.StatusMetadataKey";
dispatch_once_t _callAlreadyInvoked;
GRPCChannel *_channel;
- GRPCCompletionQueue *_completionQueue;
// The C gRPC library has less guarantees on the ordering of events than we
// do. Particularly, in the face of errors, there's no ordering guarantee at
@@ -100,19 +98,13 @@ NSString * const kGRPCStatusMetadataKey = @"io.grpc.StatusMetadataKey";
path:(NSString *)path
requestsWriter:(GRXWriter *)requestWriter {
if (!host || !path) {
- [NSException raise:NSInvalidArgumentException format:@"Neither host nor method can be nil."];
+ [NSException raise:NSInvalidArgumentException format:@"Neither host nor path can be nil."];
}
if (requestWriter.state != GRXWriterStateNotStarted) {
- [NSException raise:NSInvalidArgumentException format:@"The requests writer can't be already started."];
+ [NSException raise:NSInvalidArgumentException
+ format:@"The requests writer can't be already started."];
}
if ((self = [super init])) {
- static dispatch_once_t initialization;
- dispatch_once(&initialization, ^{
- grpc_init();
- });
-
- _completionQueue = [GRPCCompletionQueue completionQueue];
-
_channel = [GRPCChannel channelToHost:host];
_wrappedCall = [[GRPCWrappedCall alloc] initWithChannel:_channel
diff --git a/src/objective-c/GRPCClient/private/GRPCCompletionQueue.h b/src/objective-c/GRPCClient/private/GRPCCompletionQueue.h
index 603bf01939..ab8d714d22 100644
--- a/src/objective-c/GRPCClient/private/GRPCCompletionQueue.h
+++ b/src/objective-c/GRPCClient/private/GRPCCompletionQueue.h
@@ -36,15 +36,15 @@
typedef void(^GRPCQueueCompletionHandler)(bool success);
-// This class lets one more easily use grpc_completion_queue. To use it, pass
-// the value of the unmanagedQueue property of an instance of this class to
-// grpc_call_start_invoke. Then for every grpc_call_* method that accepts a tag,
-// you can pass a block of type GRPCEventHandler (remembering to cast it using
-// __bridge_retained). The block is guaranteed to eventually be called, by a
-// concurrent queue, and then released. Each such block is passed a pointer to
-// the grpc_event that carried it (in event->tag).
-// Release the GRPCCompletionQueue object only after you are not going to pass
-// any more blocks to the grpc_call that's using it.
+// This class lets one more easily use |grpc_completion_queue|. To use it, pass the value of the
+// |unmanagedQueue| property of an instance of this class to |grpc_channel_create_call|. Then for
+// every |grpc_call_*| method that accepts a tag, you can pass a block of type
+// |GRPCQueueCompletionHandler| (remembering to cast it using |__bridge_retained|). The block is
+// guaranteed to eventually be called, by a concurrent queue, and then released. Each such block is
+// passed a |bool| that tells if the operation was successful.
+//
+// Release the GRPCCompletionQueue object only after you are not going to pass any more blocks to
+// the |grpc_call| that's using it.
@interface GRPCCompletionQueue : NSObject
@property(nonatomic, readonly) grpc_completion_queue *unmanagedQueue;
diff --git a/src/objective-c/generated_libraries/RemoteTestClient/RemoteTest.podspec b/src/objective-c/generated_libraries/RemoteTestClient/RemoteTest.podspec
index 6b00efebb8..8710753e59 100644
--- a/src/objective-c/generated_libraries/RemoteTestClient/RemoteTest.podspec
+++ b/src/objective-c/generated_libraries/RemoteTestClient/RemoteTest.podspec
@@ -8,7 +8,10 @@ Pod::Spec.new do |s|
# Run protoc with the Objective-C and gRPC plugins to generate protocol messages and gRPC clients.
s.prepare_command = <<-CMD
- protoc --plugin=protoc-gen-grpc=../../../../bins/$CONFIG/grpc_objective_c_plugin --objc_out=. --grpc_out=. *.proto
+ BINDIR=../../../../bins/$CONFIG
+ PROTOC=$BINDIR/protobuf/protoc
+ PLUGIN=$BINDIR/grpc_objective_c_plugin
+ $PROTOC --plugin=protoc-gen-grpc=$PLUGIN --objc_out=. --grpc_out=. *.proto
CMD
s.subspec "Messages" do |ms|
diff --git a/src/objective-c/generated_libraries/RouteGuideClient/RouteGuide.podspec b/src/objective-c/generated_libraries/RouteGuideClient/RouteGuide.podspec
index 2c9cead7cf..23ccffe69d 100644
--- a/src/objective-c/generated_libraries/RouteGuideClient/RouteGuide.podspec
+++ b/src/objective-c/generated_libraries/RouteGuideClient/RouteGuide.podspec
@@ -8,7 +8,10 @@ Pod::Spec.new do |s|
# Run protoc with the Objective-C and gRPC plugins to generate protocol messages and gRPC clients.
s.prepare_command = <<-CMD
- protoc --plugin=protoc-gen-grpc=../../../../bins/$CONFIG/grpc_objective_c_plugin --objc_out=. --grpc_out=. *.proto
+ BINDIR=../../../../bins/$CONFIG
+ PROTOC=$BINDIR/protobuf/protoc
+ PLUGIN=$BINDIR/grpc_objective_c_plugin
+ $PROTOC --plugin=protoc-gen-grpc=$PLUGIN --objc_out=. --grpc_out=. *.proto
CMD
s.subspec "Messages" do |ms|
diff --git a/src/objective-c/tests/build_tests.sh b/src/objective-c/tests/build_tests.sh
index d98e0a769c..e7ad31e403 100755
--- a/src/objective-c/tests/build_tests.sh
+++ b/src/objective-c/tests/build_tests.sh
@@ -28,12 +28,39 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+# Don't run this script standalone. Instead, run from the repository root:
+# ./tools/run_tests/run_tests.py -l objc
+
set -e
cd $(dirname $0)
-# The local test server needs to be compiled before this because pod install of
-# gRPC renames some C gRPC files and not the server's code references to them.
-#
-# Suppress error output because Cocoapods issue #3823 causes a flooding warning.
-pod install 2>/dev/null
+hash pod 2>/dev/null || { echo >&2 "Cocoapods needs to be installed."; exit 1; }
+hash xcodebuild 2>/dev/null || {
+ echo >&2 "XCode command-line tools need to be installed."
+ exit 1
+}
+
+BINDIR=../../../bins/$CONFIG
+
+if [ ! -f $BINDIR/protobuf/protoc ]; then
+ hash protoc 2>/dev/null || {
+ echo >&2 "Can't find protoc. Make sure run_tests.py is making" \
+ "grpc_objective_c_plugin before calling this script."
+ exit 1
+ }
+ # When protoc is already installed, make doesn't compile one. Put a link
+ # there so the podspecs can do codegen using that path.
+ mkdir -p $BINDIR/protobuf
+ ln -s `which protoc` $BINDIR/protobuf/protoc
+fi
+
+[ -f $BINDIR/interop_server ] || {
+ echo >&2 "Can't find the test server. Make sure run_tests.py is making" \
+ "interop_server before calling this script. It needs to be done" \
+ "before because pod install of gRPC renames some C gRPC files" \
+ "and not the server's code references to them."
+ exit 1
+}
+
+pod install
diff --git a/src/objective-c/tests/run_tests.sh b/src/objective-c/tests/run_tests.sh
index 9afec687d6..b13c0f0633 100755
--- a/src/objective-c/tests/run_tests.sh
+++ b/src/objective-c/tests/run_tests.sh
@@ -28,6 +28,9 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+# Don't run this script standalone. Instead, run from the repository root:
+# ./tools/run_tests/run_tests.py -l objc
+
set -e
cd $(dirname $0)