Exemplo n.º 1
0
Arquivo: init.c Projeto: endobson/grpc
void grpc_init(void) {
  int i;
  gpr_once_init(&g_basic_init, do_basic_init);

  grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
  gpr_mu_lock(&g_init_mu);
  if (++g_initializations == 1) {
    gpr_time_init();
    grpc_stats_init();
    grpc_slice_intern_init();
    grpc_mdctx_global_init();
    grpc_channel_init_init();
    grpc_register_tracer(&grpc_api_trace);
    grpc_register_tracer(&grpc_trace_channel);
    grpc_register_tracer(&grpc_connectivity_state_trace);
    grpc_register_tracer(&grpc_trace_channel_stack_builder);
    grpc_register_tracer(&grpc_http1_trace);
    grpc_register_tracer(&grpc_cq_pluck_trace);  // default on
    grpc_register_tracer(&grpc_call_combiner_trace);
    grpc_register_tracer(&grpc_combiner_trace);
    grpc_register_tracer(&grpc_server_channel_trace);
    grpc_register_tracer(&grpc_bdp_estimator_trace);
    grpc_register_tracer(&grpc_cq_event_timeout_trace);  // default on
    grpc_register_tracer(&grpc_trace_operation_failures);
    grpc_register_tracer(&grpc_resource_quota_trace);
    grpc_register_tracer(&grpc_call_error_trace);
#ifndef NDEBUG
    grpc_register_tracer(&grpc_trace_pending_tags);
    grpc_register_tracer(&grpc_trace_alarm_refcount);
    grpc_register_tracer(&grpc_trace_cq_refcount);
    grpc_register_tracer(&grpc_trace_closure);
    grpc_register_tracer(&grpc_trace_error_refcount);
    grpc_register_tracer(&grpc_trace_stream_refcount);
    grpc_register_tracer(&grpc_trace_fd_refcount);
    grpc_register_tracer(&grpc_trace_metadata);
#endif
    grpc_security_pre_init();
    grpc_iomgr_init(&exec_ctx);
    gpr_timers_global_init();
    grpc_handshaker_factory_registry_init();
    grpc_security_init();
    for (i = 0; i < g_number_of_plugins; i++) {
      if (g_all_of_the_plugins[i].init != NULL) {
        g_all_of_the_plugins[i].init();
      }
    }
    /* register channel finalization AFTER all plugins, to ensure that it's run
     * at the appropriate time */
    grpc_register_security_filters();
    register_builtin_channel_init();
    grpc_tracer_init("GRPC_TRACE");
    /* no more changes to channel init pipelines */
    grpc_channel_init_finalize();
    grpc_iomgr_start(&exec_ctx);
  }
  gpr_mu_unlock(&g_init_mu);
  grpc_exec_ctx_finish(&exec_ctx);
  GRPC_API_TRACE("grpc_init(void)", 0, ());
}
Exemplo n.º 2
0
int main(int argc, char **argv) {
  grpc_test_init(argc, argv);
  grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
  grpc_iomgr_init(&exec_ctx);
  grpc_iomgr_start(&exec_ctx);
  test_unix_socket();
  test_unix_socket_path_name_too_long();
  grpc_executor_shutdown(&exec_ctx);
  grpc_iomgr_shutdown(&exec_ctx);
  grpc_exec_ctx_finish(&exec_ctx);
  return 0;
}
Exemplo n.º 3
0
int main(int argc, char **argv) {
  grpc_closure destroyed;
  grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
  grpc_test_init(argc, argv);
  grpc_iomgr_init(&exec_ctx);
  grpc_iomgr_start(&exec_ctx);
  g_pollset = gpr_zalloc(grpc_pollset_size());
  grpc_pollset_init(g_pollset, &g_mu);
  test_grpc_fd();
  test_grpc_fd_change();
  GRPC_CLOSURE_INIT(&destroyed, destroy_pollset, g_pollset,
                    grpc_schedule_on_exec_ctx);
  grpc_pollset_shutdown(&exec_ctx, g_pollset, &destroyed);
  grpc_exec_ctx_flush(&exec_ctx);
  gpr_free(g_pollset);
  grpc_iomgr_shutdown(&exec_ctx);
  grpc_exec_ctx_finish(&exec_ctx);
  return 0;
}
Exemplo n.º 4
0
int main(int argc, char **argv) {
  const char *poll_strategy = NULL;
  grpc_test_init(argc, argv);
  grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
  grpc_iomgr_init(&exec_ctx);
  grpc_iomgr_start(&exec_ctx);

  poll_strategy = grpc_get_poll_strategy_name();
  if (poll_strategy != NULL && strcmp(poll_strategy, "epollsig") == 0) {
    test_add_fd_to_pollset();
    test_threading();
  } else {
    gpr_log(GPR_INFO,
            "Skipping the test. The test is only relevant for 'epollsig' "
            "strategy. and the current strategy is: '%s'",
            poll_strategy);
  }

  grpc_iomgr_shutdown(&exec_ctx);
  grpc_exec_ctx_finish(&exec_ctx);
  return 0;
}