Merge pull request #4903 from nicolasnoble/ruby-cleanup

Cleaning up ruby extension code a bit.
pull/4871/head^2
Michael Lumish 9 years ago
commit 4f3840dc06
  1. 6
      src/ruby/ext/grpc/rb_call.c
  2. 2
      src/ruby/ext/grpc/rb_call_credentials.c
  3. 3
      src/ruby/ext/grpc/rb_event_thread.c

@ -525,12 +525,12 @@ typedef struct run_batch_stack {
grpc_status_code recv_status; grpc_status_code recv_status;
char *recv_status_details; char *recv_status_details;
size_t recv_status_details_capacity; size_t recv_status_details_capacity;
uint write_flag; unsigned write_flag;
} run_batch_stack; } run_batch_stack;
/* grpc_run_batch_stack_init ensures the run_batch_stack is properly /* grpc_run_batch_stack_init ensures the run_batch_stack is properly
* initialized */ * initialized */
static void grpc_run_batch_stack_init(run_batch_stack *st, uint write_flag) { static void grpc_run_batch_stack_init(run_batch_stack *st, unsigned write_flag) {
MEMZERO(st, run_batch_stack, 1); MEMZERO(st, run_batch_stack, 1);
grpc_metadata_array_init(&st->send_metadata); grpc_metadata_array_init(&st->send_metadata);
grpc_metadata_array_init(&st->send_trailing_metadata); grpc_metadata_array_init(&st->send_trailing_metadata);
@ -696,7 +696,7 @@ static VALUE grpc_rb_call_run_batch(VALUE self, VALUE cqueue, VALUE tag,
grpc_call_error err; grpc_call_error err;
VALUE result = Qnil; VALUE result = Qnil;
VALUE rb_write_flag = rb_ivar_get(self, id_write_flag); VALUE rb_write_flag = rb_ivar_get(self, id_write_flag);
uint write_flag = 0; unsigned write_flag = 0;
TypedData_Get_Struct(self, grpc_call, &grpc_call_data_type, call); TypedData_Get_Struct(self, grpc_call, &grpc_call_data_type, call);
/* Validate the ops args, adding them to a ruby array */ /* Validate the ops args, adding them to a ruby array */

@ -79,6 +79,7 @@ static VALUE grpc_rb_call_credentials_callback(VALUE callback_args) {
static VALUE grpc_rb_call_credentials_callback_rescue(VALUE args, static VALUE grpc_rb_call_credentials_callback_rescue(VALUE args,
VALUE exception_object) { VALUE exception_object) {
VALUE result = rb_hash_new(); VALUE result = rb_hash_new();
(void)args;
rb_hash_aset(result, rb_str_new2("metadata"), Qnil); rb_hash_aset(result, rb_str_new2("metadata"), Qnil);
/* Currently only gives the exception class name. It should be possible get /* Currently only gives the exception class name. It should be possible get
more details */ more details */
@ -132,6 +133,7 @@ static void grpc_rb_call_credentials_plugin_get_metadata(
} }
static void grpc_rb_call_credentials_plugin_destroy(void *state) { static void grpc_rb_call_credentials_plugin_destroy(void *state) {
(void)state;
// Not sure what needs to be done here // Not sure what needs to be done here
} }

@ -102,6 +102,7 @@ static void grpc_rb_event_queue_destroy() {
static void *grpc_rb_wait_for_event_no_gil(void *param) { static void *grpc_rb_wait_for_event_no_gil(void *param) {
grpc_rb_event *event = NULL; grpc_rb_event *event = NULL;
(void)param;
gpr_mu_lock(&event_queue.mu); gpr_mu_lock(&event_queue.mu);
while ((event = grpc_rb_event_queue_dequeue()) == NULL) { while ((event = grpc_rb_event_queue_dequeue()) == NULL) {
gpr_cv_wait(&event_queue.cv, gpr_cv_wait(&event_queue.cv,
@ -117,6 +118,7 @@ static void *grpc_rb_wait_for_event_no_gil(void *param) {
} }
static void grpc_rb_event_unblocking_func(void *arg) { static void grpc_rb_event_unblocking_func(void *arg) {
(void)arg;
gpr_mu_lock(&event_queue.mu); gpr_mu_lock(&event_queue.mu);
event_queue.abort = true; event_queue.abort = true;
gpr_cv_signal(&event_queue.cv); gpr_cv_signal(&event_queue.cv);
@ -127,6 +129,7 @@ static void grpc_rb_event_unblocking_func(void *arg) {
* events */ * events */
static VALUE grpc_rb_event_thread(VALUE arg) { static VALUE grpc_rb_event_thread(VALUE arg) {
grpc_rb_event *event; grpc_rb_event *event;
(void)arg;
while(true) { while(true) {
event = (grpc_rb_event*)rb_thread_call_without_gvl( event = (grpc_rb_event*)rb_thread_call_without_gvl(
grpc_rb_wait_for_event_no_gil, NULL, grpc_rb_wait_for_event_no_gil, NULL,

Loading…
Cancel
Save