explicitly convert deadline for server handlers to realtime
diff --git a/src/csharp/Grpc.Core/Internal/ServerCallHandler.cs b/src/csharp/Grpc.Core/Internal/ServerCallHandler.cs
index 9bbcb17..93e1c0b 100644
--- a/src/csharp/Grpc.Core/Internal/ServerCallHandler.cs
+++ b/src/csharp/Grpc.Core/Internal/ServerCallHandler.cs
@@ -297,8 +297,10 @@
public static ServerCallContext NewContext(ServerRpcNew newRpc, CancellationToken cancellationToken)
{
+ DateTime realtimeDeadline = newRpc.Deadline.ToClockType(GPRClockType.Realtime).ToDateTime();
+
return new ServerCallContext(
- newRpc.Method, newRpc.Host, newRpc.Deadline.ToDateTime(),
+ newRpc.Method, newRpc.Host, realtimeDeadline,
newRpc.RequestMetadata, cancellationToken);
}
}
diff --git a/src/csharp/Grpc.Core/Internal/Timespec.cs b/src/csharp/Grpc.Core/Internal/Timespec.cs
index 0e58e20..e83d21f 100644
--- a/src/csharp/Grpc.Core/Internal/Timespec.cs
+++ b/src/csharp/Grpc.Core/Internal/Timespec.cs
@@ -58,6 +58,9 @@
static extern Timespec gprsharp_inf_past(GPRClockType clockType);
[DllImport("grpc_csharp_ext.dll")]
+ static extern Timespec gprsharp_convert_clock_type(Timespec t, GPRClockType targetClock);
+
+ [DllImport("grpc_csharp_ext.dll")]
static extern int gprsharp_sizeof_timespec();
public Timespec(IntPtr tv_sec, int tv_nsec) : this(tv_sec, tv_nsec, GPRClockType.Realtime)
@@ -131,6 +134,14 @@
return tv_nsec;
}
}
+
+ /// <summary>
+ /// Converts the timespec to desired clock type.
+ /// </summary>
+ public Timespec ToClockType(GPRClockType targetClock)
+ {
+ return gprsharp_convert_clock_type(this, targetClock);
+ }
/// <summary>
/// Converts Timespec to DateTime.
diff --git a/src/csharp/ext/grpc_csharp_ext.c b/src/csharp/ext/grpc_csharp_ext.c
index 1cc44eb..7e30a84 100644
--- a/src/csharp/ext/grpc_csharp_ext.c
+++ b/src/csharp/ext/grpc_csharp_ext.c
@@ -445,6 +445,10 @@
return gpr_inf_past(clock_type);
}
+GPR_EXPORT gpr_timespec GPR_CALLTYPE gprsharp_convert_clock_type(gpr_timespec t, gpr_clock_type target_clock) {
+ return gpr_convert_clock_type(t, target_clock);
+}
+
GPR_EXPORT gpr_int32 GPR_CALLTYPE gprsharp_sizeof_timespec(void) {
return sizeof(gpr_timespec);
}