Skip to content
Snippets Groups Projects
Commit 7a3ac62d authored by Jan Tattermusch's avatar Jan Tattermusch
Browse files

explicitly convert deadline for server handlers to realtime

parent 4106259c
No related branches found
No related tags found
No related merge requests found
...@@ -297,8 +297,10 @@ namespace Grpc.Core.Internal ...@@ -297,8 +297,10 @@ namespace Grpc.Core.Internal
public static ServerCallContext NewContext(ServerRpcNew newRpc, CancellationToken cancellationToken) public static ServerCallContext NewContext(ServerRpcNew newRpc, CancellationToken cancellationToken)
{ {
DateTime realtimeDeadline = newRpc.Deadline.ToClockType(GPRClockType.Realtime).ToDateTime();
return new ServerCallContext( return new ServerCallContext(
newRpc.Method, newRpc.Host, newRpc.Deadline.ToDateTime(), newRpc.Method, newRpc.Host, realtimeDeadline,
newRpc.RequestMetadata, cancellationToken); newRpc.RequestMetadata, cancellationToken);
} }
} }
......
...@@ -57,6 +57,9 @@ namespace Grpc.Core.Internal ...@@ -57,6 +57,9 @@ namespace Grpc.Core.Internal
[DllImport("grpc_csharp_ext.dll")] [DllImport("grpc_csharp_ext.dll")]
static extern Timespec gprsharp_inf_past(GPRClockType clockType); 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")] [DllImport("grpc_csharp_ext.dll")]
static extern int gprsharp_sizeof_timespec(); static extern int gprsharp_sizeof_timespec();
...@@ -131,6 +134,14 @@ namespace Grpc.Core.Internal ...@@ -131,6 +134,14 @@ namespace Grpc.Core.Internal
return tv_nsec; 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> /// <summary>
/// Converts Timespec to DateTime. /// Converts Timespec to DateTime.
......
...@@ -445,6 +445,10 @@ GPR_EXPORT gpr_timespec GPR_CALLTYPE gprsharp_inf_past(gpr_clock_type clock_type ...@@ -445,6 +445,10 @@ GPR_EXPORT gpr_timespec GPR_CALLTYPE gprsharp_inf_past(gpr_clock_type clock_type
return gpr_inf_past(clock_type); 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) { GPR_EXPORT gpr_int32 GPR_CALLTYPE gprsharp_sizeof_timespec(void) {
return sizeof(gpr_timespec); return sizeof(gpr_timespec);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment