diff options
author | Jan Tattermusch <jtattermusch@google.com> | 2015-07-23 18:40:48 -0700 |
---|---|---|
committer | Jan Tattermusch <jtattermusch@google.com> | 2015-07-23 18:40:48 -0700 |
commit | 7a3ac62d9cdd1392b06a4bb94c57a4828ec0b32e (patch) | |
tree | cbc47b1b3a062f782bdbb7072c7a9a1bf0d0825d /src/csharp/Grpc.Core/Internal | |
parent | 4106259c79fecafa91e3bed35de008ebdc3a4857 (diff) |
explicitly convert deadline for server handlers to realtime
Diffstat (limited to 'src/csharp/Grpc.Core/Internal')
-rw-r--r-- | src/csharp/Grpc.Core/Internal/ServerCallHandler.cs | 4 | ||||
-rw-r--r-- | src/csharp/Grpc.Core/Internal/Timespec.cs | 11 |
2 files changed, 14 insertions, 1 deletions
diff --git a/src/csharp/Grpc.Core/Internal/ServerCallHandler.cs b/src/csharp/Grpc.Core/Internal/ServerCallHandler.cs index 9bbcb17266..93e1c0b294 100644 --- a/src/csharp/Grpc.Core/Internal/ServerCallHandler.cs +++ b/src/csharp/Grpc.Core/Internal/ServerCallHandler.cs @@ -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); } } diff --git a/src/csharp/Grpc.Core/Internal/Timespec.cs b/src/csharp/Grpc.Core/Internal/Timespec.cs index 0e58e2048d..e83d21f4a4 100644 --- a/src/csharp/Grpc.Core/Internal/Timespec.cs +++ b/src/csharp/Grpc.Core/Internal/Timespec.cs @@ -58,6 +58,9 @@ namespace Grpc.Core.Internal 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 @@ 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. |