From 06d4edd28355877e71733a0d246a9b5b4c67452b Mon Sep 17 00:00:00 2001 From: Alexander Polcyn Date: Tue, 21 Mar 2017 19:24:07 -0700 Subject: [PATCH] fix setting of time_check_increment in watch conn state loop --- src/ruby/ext/grpc/rb_channel.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ruby/ext/grpc/rb_channel.c b/src/ruby/ext/grpc/rb_channel.c index c12ea921c98..acf22dd46be 100644 --- a/src/ruby/ext/grpc/rb_channel.c +++ b/src/ruby/ext/grpc/rb_channel.c @@ -259,9 +259,7 @@ static void *watch_channel_state_without_gvl(void *arg) { grpc_rb_channel *wrapper = stack->wrapper; int last_state = stack->last_state; void *return_value = (void*)0; - gpr_timespec time_check_increment = gpr_time_add( - gpr_now(GPR_CLOCK_REALTIME), gpr_time_from_millis(20, GPR_TIMESPAN)); - + gpr_timespec time_check_increment; gpr_mu_lock(&wrapper->channel_mu); while(wrapper->current_connectivity_state == last_state && @@ -269,6 +267,8 @@ static void *watch_channel_state_without_gvl(void *arg) { !wrapper->safe_to_destroy && !wrapper->abort_watch_connectivity_state && gpr_time_cmp(deadline, gpr_now(GPR_CLOCK_REALTIME)) > 0) { + time_check_increment = gpr_time_add( + gpr_now(GPR_CLOCK_REALTIME), gpr_time_from_millis(20, GPR_TIMESPAN)); gpr_cv_wait(&wrapper->channel_cv, &wrapper->channel_mu, time_check_increment); } if (wrapper->current_connectivity_state != last_state) {