Hello,

I'm using grpc-c library(link <https://github.com/Juniper/grpc-c>) which 
provides a c-wrapper around the core library. The following is the pseudo 
code for a unary client call(modified to handle failure cases).

cq = grpc_completion_queue_create();
call = grpc_channel_create_call(cq);

// Start a batch on the call to do an unary RPC.
grpc_call_start_batch(call);

gpr_timespec tout = gpr_time_add(gpr_now(GPR_CLOCK_REALTIME),
                                gpr_time_from_millis(15000, GPR_TIMESPAN));

ev = grpc_completion_queue_pluck(context->gcc_cq, context, tout, NULL);
if (ev.type == GRPC_QUEUE_TIMEOUT &&
    grpc_call_cancel(context->gcc_call, NULL) == GRPC_CALL_OK) {
  gpr_log(GPR_ERROR, "Sync call timedout");
  grpc_completion_queue_shutdown(cq);
  while (grpc_completion_queue_pluck(cq, context,
                                     gpr_inf_past(GPR_CLOCK_REALTIME), NULL)
             .type != GRPC_QUEUE_SHUTDOWN)
    ;
  grpc_completion_queue_destroy(cq);
}

1. Is the above handling of completion queue destruction correct when the 
RPC times out?
2. Once in a while, I see a case where the grpc_completion_queue_pluck() 
doesn't return shutdown event ever when a timeout occurs. Can there be a 
reason this can happen?

Note that in our setup, upto 5 RPCs can be made in parallel on the same 
client.


Thanks,
Kishan.

-- 
You received this message because you are subscribed to the Google Groups 
"grpc.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/grpc-io/9721fb14-be9b-4784-869a-a7239a394ff3n%40googlegroups.com.

Reply via email to