Example #1
0
static void destroy_call(grpc_rb_call *call) {
  /* Ensure that we only try to destroy the call once */
  if (call->wrapped != NULL) {
    grpc_call_unref(call->wrapped);
    call->wrapped = NULL;
    grpc_rb_completion_queue_destroy(call->queue);
    call->queue = NULL;
  }
}
Example #2
0
static void destroy_server(grpc_rb_server *server, gpr_timespec deadline) {
  grpc_event ev;
  if (server->wrapped != NULL) {
    grpc_server_shutdown_and_notify(server->wrapped, server->queue, NULL);
    ev = rb_completion_queue_pluck(server->queue, NULL, deadline, NULL);
    if (ev.type == GRPC_QUEUE_TIMEOUT) {
      grpc_server_cancel_all_calls(server->wrapped);
      rb_completion_queue_pluck(server->queue, NULL,
                                gpr_inf_future(GPR_CLOCK_REALTIME), NULL);
    }
    grpc_server_destroy(server->wrapped);
    grpc_rb_completion_queue_destroy(server->queue);
    server->wrapped = NULL;
    server->queue = NULL;
  }
}
Example #3
0
static void destroy_server(grpc_rb_server* server, gpr_timespec deadline) {
  grpc_event ev;
  // This can be started by app or implicitly by GC. Avoid a race between these.
  if (gpr_atm_full_fetch_add(&server->shutdown_started, (gpr_atm)1) == 0) {
    if (server->wrapped != NULL) {
      grpc_server_shutdown_and_notify(server->wrapped, server->queue, NULL);
      ev = rb_completion_queue_pluck(server->queue, NULL, deadline, NULL);
      if (ev.type == GRPC_QUEUE_TIMEOUT) {
        grpc_server_cancel_all_calls(server->wrapped);
        rb_completion_queue_pluck(server->queue, NULL,
                                  gpr_inf_future(GPR_CLOCK_REALTIME), NULL);
      }
      grpc_server_destroy(server->wrapped);
      grpc_rb_completion_queue_destroy(server->queue);
      server->wrapped = NULL;
      server->queue = NULL;
    }
  }
}