Skip to content

Commit

Permalink
Fix arguments for calls to Ruby's Time.at
Browse files Browse the repository at this point in the history
`Time.at` takes microseconds as a second arg, not nanoseconds. Fixes
conversion of deadline time on the server-side.
ewr committed Jul 12, 2016
1 parent 2f17797 commit 8e769fd
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/ruby/ext/grpc/rb_grpc.c
Original file line number Diff line number Diff line change
@@ -220,7 +220,7 @@ static VALUE grpc_rb_time_val_to_time(VALUE self) {
time_const);
real_time = gpr_convert_clock_type(*time_const, GPR_CLOCK_REALTIME);
return rb_funcall(rb_cTime, id_at, 2, INT2NUM(real_time.tv_sec),
INT2NUM(real_time.tv_nsec));
INT2NUM(real_time.tv_nsec / 1000));
}

/* Invokes inspect on the ctime version of the time val. */
2 changes: 1 addition & 1 deletion src/ruby/ext/grpc/rb_server.c
Original file line number Diff line number Diff line change
@@ -218,7 +218,7 @@ static VALUE grpc_rb_server_request_call(VALUE self) {
grpc_rb_sNewServerRpc, rb_str_new2(st.details.method),
rb_str_new2(st.details.host),
rb_funcall(rb_cTime, id_at, 2, INT2NUM(deadline.tv_sec),
INT2NUM(deadline.tv_nsec)),
INT2NUM(deadline.tv_nsec / 1000)),
grpc_rb_md_ary_to_h(&st.md_ary), grpc_rb_wrap_call(call, call_queue),
NULL);
grpc_request_call_stack_cleanup(&st);

0 comments on commit 8e769fd

Please sign in to comment.