Completes merge
diff --git a/src/ruby/ext/grpc/rb_credentials.c b/src/ruby/ext/grpc/rb_credentials.c
index 31f47f3..43cc21a 100644
--- a/src/ruby/ext/grpc/rb_credentials.c
+++ b/src/ruby/ext/grpc/rb_credentials.c
@@ -214,6 +214,8 @@
VALUE pem_cert_chain = Qnil;
grpc_rb_credentials *wrapper = NULL;
grpc_credentials *creds = NULL;
+ grpc_ssl_pem_key_cert_pair key_cert_pair;
+ MEMZERO(&key_cert_pair, grpc_ssl_pem_key_cert_pair, 1);
/* TODO: Remove mandatory arg when we support default roots. */
/* "12" == 1 mandatory arg, 2 (credentials) is optional */
rb_scan_args(argc, argv, "12", &pem_root_certs, &pem_private_key,
@@ -228,8 +230,8 @@
if (pem_private_key == Qnil && pem_cert_chain == Qnil) {
creds = grpc_ssl_credentials_create(RSTRING_PTR(pem_root_certs), NULL);
} else {
- grpc_ssl_pem_key_cert_pair key_cert_pair = {RSTRING_PTR(pem_private_key),
- RSTRING_PTR(pem_cert_chain)};
+ key_cert_pair.private_key = RSTRING_PTR(pem_private_key);
+ key_cert_pair.cert_chain = RSTRING_PTR(pem_cert_chain);
creds = grpc_ssl_credentials_create(
RSTRING_PTR(pem_root_certs), &key_cert_pair);
}
diff --git a/src/ruby/ext/grpc/rb_server.c b/src/ruby/ext/grpc/rb_server.c
index ef2a9f1..436d006 100644
--- a/src/ruby/ext/grpc/rb_server.c
+++ b/src/ruby/ext/grpc/rb_server.c
@@ -223,7 +223,7 @@
VALUE port = Qnil;
VALUE is_secure = Qnil;
grpc_rb_server *s = NULL;
- int added_ok = 0;
+ int recvd_port = 0;
/* "11" == 1 mandatory args, 1 (is_secure) is optional */
rb_scan_args(argc, argv, "11", &port, &is_secure);
@@ -233,22 +233,22 @@
rb_raise(rb_eRuntimeError, "closed!");
return Qnil;
} else if (is_secure == Qnil || TYPE(is_secure) != T_TRUE) {
- added_ok = grpc_server_add_http2_port(s->wrapped, StringValueCStr(port));
- if (added_ok == 0) {
+ recvd_port = grpc_server_add_http2_port(s->wrapped, StringValueCStr(port));
+ if (recvd_port == 0) {
rb_raise(rb_eRuntimeError,
"could not add port %s to server, not sure why",
StringValueCStr(port));
}
} else if (TYPE(is_secure) != T_FALSE) {
- added_ok =
+ recvd_port =
grpc_server_add_secure_http2_port(s->wrapped, StringValueCStr(port));
- if (added_ok == 0) {
+ if (recvd_port == 0) {
rb_raise(rb_eRuntimeError,
"could not add secure port %s to server, not sure why",
StringValueCStr(port));
}
}
- return Qnil;
+ return INT2NUM(recvd_port);
}
void Init_google_rpc_server() {
diff --git a/src/ruby/spec/client_server_spec.rb b/src/ruby/spec/client_server_spec.rb
index ffd0217..567206e 100644
--- a/src/ruby/spec/client_server_spec.rb
+++ b/src/ruby/spec/client_server_spec.rb
@@ -329,7 +329,6 @@
@server_queue = GRPC::Core::CompletionQueue.new
@server = GRPC::Core::Server.new(@server_queue, nil)
server_port = @server.add_http2_port(server_host)
- puts "Server running on #{server_port}"
@server.start
@ch = Channel.new("0.0.0.0:#{server_port}", nil)
end
@@ -357,7 +356,7 @@
server_port = @server.add_http2_port(server_host, true)
@server.start
args = { Channel::SSL_TARGET => 'foo.test.google.com' }
- @ch = Channel.new("localhost:#{server_port}", args,
+ @ch = Channel.new("0.0.0.0:#{server_port}", args,
GRPC::Core::Credentials.new(certs[0], nil, nil))
end