grpc-c icon indicating copy to clipboard operation
grpc-c copied to clipboard

Timeout handling in grpc_c_read asserts

Open aniruddha-a opened this issue 2 months ago • 0 comments

When using a timeout in grpc_c_read() (last argument), we hit an assert in the gRPC core lib! Reason being - use of GPR_CLOCK_MONOTONIC instead of GPR_TIMESPAN

The following fix is needed:

--- a/lib/src/stream_ops.c
+++ b/lib/src/stream_ops.c
@@ -16,7 +16,7 @@ gpr_timespec grpc_c_deadline_from_timeout(long timeout) {
     deadline = gpr_time_0(GPR_CLOCK_MONOTONIC);
   } else {
     deadline = gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC),
-                            gpr_time_from_millis(timeout, GPR_CLOCK_MONOTONIC));
+                            gpr_time_from_millis(timeout, GPR_TIMESPAN));
   }

aniruddha-a avatar Oct 12 '25 12:10 aniruddha-a