aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/ruby/ext/grpc/rb_call.c
diff options
context:
space:
mode:
authorGravatar Alexander Polcyn <apolcyn@google.com>2017-03-23 22:18:02 -0700
committerGravatar Alexander Polcyn <apolcyn@google.com>2017-03-23 22:18:02 -0700
commit34bb6df108742cf5c17d019ee5d010c7ff12a55b (patch)
tree146d66b566f4509adfab794799a02daacf2b73a0 /src/ruby/ext/grpc/rb_call.c
parent27338de44531467941f5dafb823560c0e1e3d401 (diff)
allocated run batch stack on the heap
Diffstat (limited to 'src/ruby/ext/grpc/rb_call.c')
-rw-r--r--src/ruby/ext/grpc/rb_call.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/src/ruby/ext/grpc/rb_call.c b/src/ruby/ext/grpc/rb_call.c
index 82d340b254..cf62564667 100644
--- a/src/ruby/ext/grpc/rb_call.c
+++ b/src/ruby/ext/grpc/rb_call.c
@@ -784,7 +784,7 @@ static VALUE grpc_run_batch_stack_build_result(run_batch_stack *st) {
Only one operation of each type can be active at once in any given
batch */
static VALUE grpc_rb_call_run_batch(VALUE self, VALUE ops_hash) {
- run_batch_stack st;
+ run_batch_stack *st;
grpc_rb_call *call = NULL;
grpc_event ev;
grpc_call_error err;
@@ -792,6 +792,8 @@ static VALUE grpc_rb_call_run_batch(VALUE self, VALUE ops_hash) {
VALUE rb_write_flag = rb_ivar_get(self, id_write_flag);
unsigned write_flag = 0;
void *tag = (void*)&st;
+ st = gpr_malloc(sizeof(run_batch_stack));
+
if (RTYPEDDATA_DATA(self) == NULL) {
rb_raise(grpc_rb_eCallError, "Cannot run batch on closed call");
return Qnil;
@@ -806,14 +808,15 @@ static VALUE grpc_rb_call_run_batch(VALUE self, VALUE ops_hash) {
if (rb_write_flag != Qnil) {
write_flag = NUM2UINT(rb_write_flag);
}
- grpc_run_batch_stack_init(&st, write_flag);
- grpc_run_batch_stack_fill_ops(&st, ops_hash);
+ grpc_run_batch_stack_init(st, write_flag);
+ grpc_run_batch_stack_fill_ops(st, ops_hash);
/* call grpc_call_start_batch, then wait for it to complete using
* pluck_event */
- err = grpc_call_start_batch(call->wrapped, st.ops, st.op_num, tag, NULL);
+ err = grpc_call_start_batch(call->wrapped, st->ops, st->op_num, tag, NULL);
if (err != GRPC_CALL_OK) {
- grpc_run_batch_stack_cleanup(&st);
+ grpc_run_batch_stack_cleanup(st);
+ gpr_free(st);
rb_raise(grpc_rb_eCallError,
"grpc_call_start_batch failed with %s (code=%d)",
grpc_call_error_detail_of(err), err);
@@ -826,8 +829,9 @@ static VALUE grpc_rb_call_run_batch(VALUE self, VALUE ops_hash) {
}
/* Build and return the BatchResult struct result,
if there is an error, it's reflected in the status */
- result = grpc_run_batch_stack_build_result(&st);
- grpc_run_batch_stack_cleanup(&st);
+ result = grpc_run_batch_stack_build_result(st);
+ grpc_run_batch_stack_cleanup(st);
+ gpr_free(st);
return result;
}