explicitly convert deadline for server handlers to realtime

pull/2643/head
Jan Tattermusch 9 years ago
parent 4106259c79
commit 7a3ac62d9c
  1. 4
      src/csharp/Grpc.Core/Internal/ServerCallHandler.cs
  2. 11
      src/csharp/Grpc.Core/Internal/Timespec.cs
  3. 4
      src/csharp/ext/grpc_csharp_ext.c

@ -297,8 +297,10 @@ namespace Grpc.Core.Internal
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);
}
}

@ -57,6 +57,9 @@ namespace Grpc.Core.Internal
[DllImport("grpc_csharp_ext.dll")]
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();
@ -131,6 +134,14 @@ namespace Grpc.Core.Internal
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.

@ -445,6 +445,10 @@ GPR_EXPORT gpr_timespec GPR_CALLTYPE gprsharp_inf_past(gpr_clock_type 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) {
return sizeof(gpr_timespec);
}

Loading…
Cancel
Save