aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar murgatroid99 <mlumish@google.com>2016-05-18 09:49:42 -0700
committerGravatar murgatroid99 <mlumish@google.com>2016-05-18 09:49:42 -0700
commit83939ce3ac1d22abf3e2878d22df009ccfde5d0b (patch)
treebf50231ada83a933ba6c5deb2707aed963e97fd0
parentb0b5380daab880391b7cf8ced2de10478d331dac (diff)
parent746ea97afdcdffa074d4710d6706e4e988d4ad8e (diff)
Merge branch 'ruby_signal_handling_improvement' into ruby_explicit_kw_args
-rw-r--r--src/ruby/ext/grpc/rb_completion_queue.c18
1 files changed, 6 insertions, 12 deletions
diff --git a/src/ruby/ext/grpc/rb_completion_queue.c b/src/ruby/ext/grpc/rb_completion_queue.c
index 605c7408b4..b6ddbe88dc 100644
--- a/src/ruby/ext/grpc/rb_completion_queue.c
+++ b/src/ruby/ext/grpc/rb_completion_queue.c
@@ -62,13 +62,10 @@ static void *grpc_rb_completion_queue_next_no_gil(void *param) {
gpr_timespec deadline;
do {
deadline = gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), increment);
- if (gpr_time_cmp(deadline, next_call->timeout) > 0) {
- // Then we have run out of time
- break;
- }
next_call->event = grpc_completion_queue_next(next_call->cq,
deadline, NULL);
- if (next_call->event.success) {
+ if (next_call->event.type != GRPC_QUEUE_TIMEOUT ||
+ gpr_time_cmp(deadline, next_call->timeout) > 0) {
break;
}
} while (!next_call->interrupted);
@@ -82,14 +79,11 @@ static void *grpc_rb_completion_queue_pluck_no_gil(void *param) {
gpr_timespec deadline;
do {
deadline = gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), increment);
- if (gpr_time_cmp(deadline, next_call->timeout) > 0) {
- // Then we have run out of time
- break;
- }
next_call->event = grpc_completion_queue_pluck(next_call->cq,
next_call->tag,
deadline, NULL);
- if (next_call->event.type != GRPC_QUEUE_TIMEOUT) {
+ if (next_call->event.type != GRPC_QUEUE_TIMEOUT ||
+ gpr_time_cmp(deadline, next_call->timeout) > 0) {
break;
}
} while (!next_call->interrupted);
@@ -195,8 +189,8 @@ grpc_event grpc_rb_completion_queue_pluck_event(VALUE self, VALUE tag,
The basic reason we need this relatively complicated construction is that
we need to re-acquire the GVL when an interrupt comes in, so that the ruby
- interpeter can do what it needs to do with the interrupt. But we also need
- to get back to plucking when */
+ interpreter can do what it needs to do with the interrupt. But we also need
+ to get back to plucking when the interrupt has been handled. */
do {
next_call.interrupted = 0;
rb_thread_call_without_gvl(grpc_rb_completion_queue_pluck_no_gil,