aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--src/cpp/util/time.cc2
-rw-r--r--src/node/ext/completion_queue_async_worker.cc3
-rw-r--r--src/node/ext/server.cc3
-rw-r--r--src/node/ext/timeval.cc8
-rw-r--r--src/python/src/grpc/_adapter/_c/utility.c1
-rw-r--r--src/ruby/ext/grpc/rb_grpc.c13
-rw-r--r--test/cpp/end2end/end2end_test.cc5
-rw-r--r--test/cpp/end2end/thread_stress_test.cc2
-rw-r--r--test/cpp/util/time_test.cc9
9 files changed, 31 insertions, 15 deletions
diff --git a/src/cpp/util/time.cc b/src/cpp/util/time.cc
index 99b857a428..a814cad452 100644
--- a/src/cpp/util/time.cc
+++ b/src/cpp/util/time.cc
@@ -59,6 +59,7 @@ void Timepoint2Timespec(const system_clock::time_point& from,
nanoseconds nsecs = duration_cast<nanoseconds>(deadline - secs);
to->tv_sec = secs.count();
to->tv_nsec = nsecs.count();
+ to->clock_type = GPR_CLOCK_REALTIME;
}
void TimepointHR2Timespec(const high_resolution_clock::time_point& from,
@@ -74,6 +75,7 @@ void TimepointHR2Timespec(const high_resolution_clock::time_point& from,
nanoseconds nsecs = duration_cast<nanoseconds>(deadline - secs);
to->tv_sec = secs.count();
to->tv_nsec = nsecs.count();
+ to->clock_type = GPR_CLOCK_REALTIME;
}
system_clock::time_point Timespec2Timepoint(gpr_timespec t) {
diff --git a/src/node/ext/completion_queue_async_worker.cc b/src/node/ext/completion_queue_async_worker.cc
index 4be208c82d..1215c97e19 100644
--- a/src/node/ext/completion_queue_async_worker.cc
+++ b/src/node/ext/completion_queue_async_worker.cc
@@ -62,7 +62,8 @@ CompletionQueueAsyncWorker::CompletionQueueAsyncWorker()
CompletionQueueAsyncWorker::~CompletionQueueAsyncWorker() {}
void CompletionQueueAsyncWorker::Execute() {
- result = grpc_completion_queue_next(queue, gpr_inf_future);
+ result =
+ grpc_completion_queue_next(queue, gpr_inf_future(GPR_CLOCK_REALTIME));
if (!result.success) {
SetErrorMessage("The batch encountered an error");
}
diff --git a/src/node/ext/server.cc b/src/node/ext/server.cc
index 51c55ba965..34cde9ffab 100644
--- a/src/node/ext/server.cc
+++ b/src/node/ext/server.cc
@@ -161,7 +161,8 @@ void Server::ShutdownServer() {
grpc_server_shutdown_and_notify(this->wrapped_server,
this->shutdown_queue,
NULL);
- grpc_completion_queue_pluck(this->shutdown_queue, NULL, gpr_inf_future);
+ grpc_completion_queue_pluck(this->shutdown_queue, NULL,
+ gpr_inf_future(GPR_CLOCK_REALTIME));
this->wrapped_server = NULL;
}
}
diff --git a/src/node/ext/timeval.cc b/src/node/ext/timeval.cc
index bc3237f7a6..e3620fc91d 100644
--- a/src/node/ext/timeval.cc
+++ b/src/node/ext/timeval.cc
@@ -42,18 +42,18 @@ namespace node {
gpr_timespec MillisecondsToTimespec(double millis) {
if (millis == std::numeric_limits<double>::infinity()) {
- return gpr_inf_future;
+ return gpr_inf_future(GPR_CLOCK_REALTIME);
} else if (millis == -std::numeric_limits<double>::infinity()) {
- return gpr_inf_past;
+ return gpr_inf_past(GPR_CLOCK_REALTIME);
} else {
return gpr_time_from_micros(static_cast<int64_t>(millis * 1000));
}
}
double TimespecToMilliseconds(gpr_timespec timespec) {
- if (gpr_time_cmp(timespec, gpr_inf_future) == 0) {
+ if (gpr_time_cmp(timespec, gpr_inf_future(GPR_CLOCK_REALTIME)) == 0) {
return std::numeric_limits<double>::infinity();
- } else if (gpr_time_cmp(timespec, gpr_inf_past) == 0) {
+ } else if (gpr_time_cmp(timespec, gpr_inf_past(GPR_CLOCK_REALTIME)) == 0) {
return -std::numeric_limits<double>::infinity();
} else {
return (static_cast<double>(timespec.tv_sec) * 1000 +
diff --git a/src/python/src/grpc/_adapter/_c/utility.c b/src/python/src/grpc/_adapter/_c/utility.c
index b82b042268..000c8d0c38 100644
--- a/src/python/src/grpc/_adapter/_c/utility.c
+++ b/src/python/src/grpc/_adapter/_c/utility.c
@@ -390,6 +390,7 @@ gpr_timespec pygrpc_cast_double_to_gpr_timespec(double seconds) {
} else {
result.tv_sec = (time_t)seconds;
result.tv_nsec = ((seconds - result.tv_sec) * 1e9);
+ result.clock_type = GPR_CLOCK_REALTIME;
}
return result;
}
diff --git a/src/ruby/ext/grpc/rb_grpc.c b/src/ruby/ext/grpc/rb_grpc.c
index 706a2a75c2..b0ecbce091 100644
--- a/src/ruby/ext/grpc/rb_grpc.c
+++ b/src/ruby/ext/grpc/rb_grpc.c
@@ -222,24 +222,31 @@ static VALUE grpc_rb_time_val_to_s(VALUE self) {
return rb_funcall(grpc_rb_time_val_to_time(self), id_to_s, 0);
}
+static gpr_timespec zero_realtime;
+static gpr_timespec inf_future_realtime;
+static gpr_timespec inf_past_realtime;
+
/* Adds a module with constants that map to gpr's static timeval structs. */
static void Init_grpc_time_consts() {
VALUE grpc_rb_mTimeConsts =
rb_define_module_under(grpc_rb_mGrpcCore, "TimeConsts");
grpc_rb_cTimeVal =
rb_define_class_under(grpc_rb_mGrpcCore, "TimeSpec", rb_cObject);
+ zero_realtime = gpr_time_0(GPR_CLOCK_REALTIME);
+ inf_future_realtime = gpr_inf_future(GPR_CLOCK_REALTIME);
+ inf_past_realtime = gpr_inf_past(GPR_CLOCK_REALTIME);
rb_define_const(
grpc_rb_mTimeConsts, "ZERO",
TypedData_Wrap_Struct(grpc_rb_cTimeVal, &grpc_rb_timespec_data_type,
- (void *)&gpr_time_0));
+ (void *)&zero_realtime));
rb_define_const(
grpc_rb_mTimeConsts, "INFINITE_FUTURE",
TypedData_Wrap_Struct(grpc_rb_cTimeVal, &grpc_rb_timespec_data_type,
- (void *)&gpr_inf_future(GPR_CLOCK_REALTIME)));
+ (void *)&inf_future_realtime));
rb_define_const(
grpc_rb_mTimeConsts, "INFINITE_PAST",
TypedData_Wrap_Struct(grpc_rb_cTimeVal, &grpc_rb_timespec_data_type,
- (void *)&gpr_inf_past(GPR_CLOCK_REALTIME)));
+ (void *)&inf_past_realtime));
rb_define_method(grpc_rb_cTimeVal, "to_time", grpc_rb_time_val_to_time, 0);
rb_define_method(grpc_rb_cTimeVal, "inspect", grpc_rb_time_val_inspect, 0);
rb_define_method(grpc_rb_cTimeVal, "to_s", grpc_rb_time_val_to_s, 0);
diff --git a/test/cpp/end2end/end2end_test.cc b/test/cpp/end2end/end2end_test.cc
index f0d9f75214..403fffed5c 100644
--- a/test/cpp/end2end/end2end_test.cc
+++ b/test/cpp/end2end/end2end_test.cc
@@ -75,7 +75,7 @@ const char* kServerCancelAfterReads = "cancel_after_reads";
void MaybeEchoDeadline(ServerContext* context, const EchoRequest* request,
EchoResponse* response) {
if (request->has_param() && request->param().echo_deadline()) {
- gpr_timespec deadline = gpr_inf_future;
+ gpr_timespec deadline = gpr_inf_future(GPR_CLOCK_REALTIME);
if (context->deadline() != system_clock::time_point::max()) {
Timepoint2Timespec(context->deadline(), &deadline);
}
@@ -373,7 +373,8 @@ TEST_F(End2endTest, EchoDeadlineForNoDeadlineRpc) {
Status s = stub_->Echo(&context, request, &response);
EXPECT_EQ(response.message(), request.message());
EXPECT_TRUE(s.ok());
- EXPECT_EQ(response.param().request_deadline(), gpr_inf_future.tv_sec);
+ EXPECT_EQ(response.param().request_deadline(),
+ gpr_inf_future(GPR_CLOCK_REALTIME).tv_sec);
}
TEST_F(End2endTest, UnimplementedRpc) {
diff --git a/test/cpp/end2end/thread_stress_test.cc b/test/cpp/end2end/thread_stress_test.cc
index 0b4d942566..cae34455b9 100644
--- a/test/cpp/end2end/thread_stress_test.cc
+++ b/test/cpp/end2end/thread_stress_test.cc
@@ -71,7 +71,7 @@ namespace {
void MaybeEchoDeadline(ServerContext* context, const EchoRequest* request,
EchoResponse* response) {
if (request->has_param() && request->param().echo_deadline()) {
- gpr_timespec deadline = gpr_inf_future;
+ gpr_timespec deadline = gpr_inf_future(GPR_CLOCK_REALTIME);
if (context->deadline() != system_clock::time_point::max()) {
Timepoint2Timespec(context->deadline(), &deadline);
}
diff --git a/test/cpp/util/time_test.cc b/test/cpp/util/time_test.cc
index a3cfb1c961..1770a80574 100644
--- a/test/cpp/util/time_test.cc
+++ b/test/cpp/util/time_test.cc
@@ -47,6 +47,7 @@ class TimeTest : public ::testing::Test {};
TEST_F(TimeTest, AbsolutePointTest) {
long us = 10000000L;
gpr_timespec ts = gpr_time_from_micros(us);
+ ts.clock_type = GPR_CLOCK_REALTIME;
system_clock::time_point tp{microseconds(us)};
system_clock::time_point tp_converted = Timespec2Timepoint(ts);
gpr_timespec ts_converted;
@@ -61,15 +62,17 @@ TEST_F(TimeTest, AbsolutePointTest) {
// gpr_inf_future is treated specially and mapped to/from time_point::max()
TEST_F(TimeTest, InfFuture) {
EXPECT_EQ(system_clock::time_point::max(),
- Timespec2Timepoint(gpr_inf_future));
+ Timespec2Timepoint(gpr_inf_future(GPR_CLOCK_REALTIME)));
gpr_timespec from_time_point_max;
Timepoint2Timespec(system_clock::time_point::max(), &from_time_point_max);
- EXPECT_EQ(0, gpr_time_cmp(gpr_inf_future, from_time_point_max));
+ EXPECT_EQ(
+ 0, gpr_time_cmp(gpr_inf_future(GPR_CLOCK_REALTIME), from_time_point_max));
// This will cause an overflow
Timepoint2Timespec(
std::chrono::time_point<system_clock, std::chrono::seconds>::max(),
&from_time_point_max);
- EXPECT_EQ(0, gpr_time_cmp(gpr_inf_future, from_time_point_max));
+ EXPECT_EQ(
+ 0, gpr_time_cmp(gpr_inf_future(GPR_CLOCK_REALTIME), from_time_point_max));
}
} // namespace