aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/core/lib/client_config/resolvers/sockaddr_resolver.c39
-rw-r--r--src/core/lib/iomgr/pollset_set_windows.c2
-rw-r--r--src/ruby/ext/grpc/rb_byte_buffer.c15
-rw-r--r--src/ruby/ext/grpc/rb_call.c14
4 files changed, 25 insertions, 45 deletions
diff --git a/src/core/lib/client_config/resolvers/sockaddr_resolver.c b/src/core/lib/client_config/resolvers/sockaddr_resolver.c
index 5c5133649a..c787bd57d6 100644
--- a/src/core/lib/client_config/resolvers/sockaddr_resolver.c
+++ b/src/core/lib/client_config/resolvers/sockaddr_resolver.c
@@ -267,46 +267,17 @@ static grpc_resolver *sockaddr_create(
r->lb_policy_name = NULL;
if (0 != strcmp(args->uri->query, "")) {
gpr_slice query_slice;
- gpr_slice_buffer query_parts; /* the &-separated elements of the query */
- gpr_slice_buffer query_param_parts; /* the =-separated subelements */
+ gpr_slice_buffer query_parts;
query_slice =
gpr_slice_new(args->uri->query, strlen(args->uri->query), do_nothing);
gpr_slice_buffer_init(&query_parts);
- gpr_slice_buffer_init(&query_param_parts);
- /* the query can contain "lb_policy=<policy>" and "lb_enabled=<1|0>" */
-
- bool lb_enabled;
- gpr_slice_split(query_slice, "&", &query_parts);
- for (i = 0; i < query_parts.count; i++) {
- gpr_slice_split(query_parts.slices[i], "=", &query_param_parts);
- GPR_ASSERT(query_param_parts.count == 2);
- if (0 == gpr_slice_str_cmp(query_param_parts.slices[0], "lb_policy")) {
- r->lb_policy_name =
- gpr_dump_slice(query_param_parts.slices[1], GPR_DUMP_ASCII);
- } else if (0 ==
- gpr_slice_str_cmp(query_param_parts.slices[0], "lb_enabled")) {
- if (0 != gpr_slice_str_cmp(query_param_parts.slices[1], "0")) {
- /* anything other than 0 is taken to be true */
- lb_enabled = true;
- }
- } else {
- gpr_log(GPR_ERROR, "invalid query element value: '%s'",
- query_parts.slices[0]);
- }
- gpr_slice_buffer_reset_and_unref(&query_param_parts);
- }
-
- if (strcmp("grpclb", r->lb_policy_name) == 0 && !lb_enabled) {
- /* we want grpclb but the "resolved" addresses aren't LB enabled. Bail
- * out, as this is meant mostly for tests. */
- gpr_log(GPR_ERROR,
- "Requested 'grpclb' LB policy but resolved addresses don't "
- "support load balancing.");
- abort();
+ gpr_slice_split(query_slice, "=", &query_parts);
+ GPR_ASSERT(query_parts.count == 2);
+ if (0 == gpr_slice_str_cmp(query_parts.slices[0], "lb_policy")) {
+ r->lb_policy_name = gpr_dump_slice(query_parts.slices[1], GPR_DUMP_ASCII);
}
gpr_slice_buffer_destroy(&query_parts);
- gpr_slice_buffer_destroy(&query_param_parts);
gpr_slice_unref(query_slice);
}
if (r->lb_policy_name == NULL) {
diff --git a/src/core/lib/iomgr/pollset_set_windows.c b/src/core/lib/iomgr/pollset_set_windows.c
index 0b14e446ae..720fc331ed 100644
--- a/src/core/lib/iomgr/pollset_set_windows.c
+++ b/src/core/lib/iomgr/pollset_set_windows.c
@@ -37,7 +37,7 @@
#include "src/core/lib/iomgr/pollset_set_windows.h"
-grpc_pollset_set* grpc_pollset_set_create(pollset_set) { return NULL; }
+grpc_pollset_set* grpc_pollset_set_create(void) { return NULL; }
void grpc_pollset_set_destroy(grpc_pollset_set* pollset_set) {}
diff --git a/src/ruby/ext/grpc/rb_byte_buffer.c b/src/ruby/ext/grpc/rb_byte_buffer.c
index db7cac363a..9b617e13d3 100644
--- a/src/ruby/ext/grpc/rb_byte_buffer.c
+++ b/src/ruby/ext/grpc/rb_byte_buffer.c
@@ -50,21 +50,18 @@ grpc_byte_buffer* grpc_rb_s_to_byte_buffer(char *string, size_t length) {
}
VALUE grpc_rb_byte_buffer_to_s(grpc_byte_buffer *buffer) {
- size_t length = 0;
- char *string = NULL;
- size_t offset = 0;
+ VALUE rb_string;
grpc_byte_buffer_reader reader;
gpr_slice next;
if (buffer == NULL) {
return Qnil;
-
}
- length = grpc_byte_buffer_length(buffer);
- string = xmalloc(length + 1);
+ rb_string = rb_str_buf_new(grpc_byte_buffer_length(buffer));
grpc_byte_buffer_reader_init(&reader, buffer);
while (grpc_byte_buffer_reader_next(&reader, &next) != 0) {
- memcpy(string + offset, GPR_SLICE_START_PTR(next), GPR_SLICE_LENGTH(next));
- offset += GPR_SLICE_LENGTH(next);
+ rb_str_cat(rb_string, (const char *) GPR_SLICE_START_PTR(next),
+ GPR_SLICE_LENGTH(next));
+ gpr_slice_unref(next);
}
- return rb_str_new(string, length);
+ return rb_string;
}
diff --git a/src/ruby/ext/grpc/rb_call.c b/src/ruby/ext/grpc/rb_call.c
index cd0aa6aaf2..b0829efdc7 100644
--- a/src/ruby/ext/grpc/rb_call.c
+++ b/src/ruby/ext/grpc/rb_call.c
@@ -551,13 +551,26 @@ static void grpc_run_batch_stack_init(run_batch_stack *st,
/* grpc_run_batch_stack_cleanup ensures the run_batch_stack is properly
* cleaned up */
static void grpc_run_batch_stack_cleanup(run_batch_stack *st) {
+ size_t i = 0;
+
grpc_metadata_array_destroy(&st->send_metadata);
grpc_metadata_array_destroy(&st->send_trailing_metadata);
grpc_metadata_array_destroy(&st->recv_metadata);
grpc_metadata_array_destroy(&st->recv_trailing_metadata);
+
if (st->recv_status_details != NULL) {
gpr_free(st->recv_status_details);
}
+
+ if (st->recv_message != NULL) {
+ grpc_byte_buffer_destroy(st->recv_message);
+ }
+
+ for (i = 0; i < st->op_num; i++) {
+ if (st->ops[i].op == GRPC_OP_SEND_MESSAGE) {
+ grpc_byte_buffer_destroy(st->ops[i].data.send_message);
+ }
+ }
}
/* grpc_run_batch_stack_fill_ops fills the run_batch_stack ops array from
@@ -643,7 +656,6 @@ static VALUE grpc_run_batch_stack_build_result(run_batch_stack *st) {
break;
case GRPC_OP_SEND_MESSAGE:
rb_struct_aset(result, sym_send_message, Qtrue);
- grpc_byte_buffer_destroy(st->ops[i].data.send_message);
break;
case GRPC_OP_SEND_CLOSE_FROM_CLIENT:
rb_struct_aset(result, sym_send_close, Qtrue);