void grpc_init(void) { int i; gpr_once_init(&g_basic_init, do_basic_init); gpr_mu_lock(&g_init_mu); if (++g_initializations == 1) { gpr_time_init(); grpc_slice_intern_init(); grpc_mdctx_global_init(); grpc_channel_init_init(); grpc_register_tracer("api", &grpc_api_trace); grpc_register_tracer("channel", &grpc_trace_channel); grpc_register_tracer("connectivity_state", &grpc_connectivity_state_trace); grpc_register_tracer("channel_stack_builder", &grpc_trace_channel_stack_builder); grpc_register_tracer("http1", &grpc_http1_trace); grpc_register_tracer("queue_pluck", &grpc_cq_pluck_trace); grpc_register_tracer("combiner", &grpc_combiner_trace); grpc_register_tracer("server_channel", &grpc_server_channel_trace); grpc_register_tracer("bdp_estimator", &grpc_bdp_estimator_trace); // Default pluck trace to 1 grpc_cq_pluck_trace = 1; grpc_register_tracer("queue_timeout", &grpc_cq_event_timeout_trace); // Default timeout trace to 1 grpc_cq_event_timeout_trace = 1; grpc_register_tracer("op_failure", &grpc_trace_operation_failures); grpc_register_tracer("resource_quota", &grpc_resource_quota_trace); grpc_register_tracer("call_error", &grpc_call_error_trace); #ifndef NDEBUG grpc_register_tracer("pending_tags", &grpc_trace_pending_tags); #endif grpc_security_pre_init(); grpc_iomgr_init(); grpc_executor_init(); 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(); } gpr_mu_unlock(&g_init_mu); GRPC_API_TRACE("grpc_init(void)", 0, ()); }
void grpc_iomgr_init(grpc_exec_ctx *exec_ctx) { g_shutdown = 0; gpr_mu_init(&g_mu); gpr_cv_init(&g_rcv); grpc_exec_ctx_global_init(); grpc_executor_init(exec_ctx); grpc_timer_list_init(gpr_now(GPR_CLOCK_MONOTONIC)); g_root_object.next = g_root_object.prev = &g_root_object; g_root_object.name = "root"; grpc_network_status_init(); grpc_iomgr_platform_init(); }
void grpc_init(void) { int i; gpr_once_init(&g_basic_init, do_basic_init); gpr_mu_lock(&g_init_mu); if (++g_initializations == 1) { gpr_time_init(); grpc_mdctx_global_init(); grpc_lb_policy_registry_init(grpc_pick_first_lb_factory_create()); grpc_register_lb_policy(grpc_pick_first_lb_factory_create()); grpc_register_lb_policy(grpc_round_robin_lb_factory_create()); grpc_resolver_registry_init(GRPC_DEFAULT_NAME_PREFIX); grpc_register_resolver_type(grpc_dns_resolver_factory_create()); grpc_register_resolver_type(grpc_ipv4_resolver_factory_create()); grpc_register_resolver_type(grpc_ipv6_resolver_factory_create()); #ifdef GPR_POSIX_SOCKET grpc_register_resolver_type(grpc_unix_resolver_factory_create()); #endif grpc_register_tracer("api", &grpc_api_trace); grpc_register_tracer("channel", &grpc_trace_channel); grpc_register_tracer("http", &grpc_http_trace); grpc_register_tracer("flowctl", &grpc_flowctl_trace); grpc_register_tracer("connectivity_state", &grpc_connectivity_state_trace); grpc_security_pre_init(); grpc_iomgr_init(); grpc_executor_init(); grpc_tracer_init("GRPC_TRACE"); /* Only initialize census if noone else has. */ if (census_enabled() == CENSUS_FEATURE_NONE) { if (census_initialize(census_supported())) { /* enable all features. */ gpr_log(GPR_ERROR, "Could not initialize census."); } } gpr_timers_global_init(); grpc_cq_global_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(); } } } gpr_mu_unlock(&g_init_mu); GRPC_API_TRACE("grpc_init(void)", 0, ()); }
void grpc_init(void) { int i; gpr_once_init(&g_basic_init, do_basic_init); gpr_mu_lock(&g_init_mu); if (++g_initializations == 1) { gpr_time_init(); grpc_mdctx_global_init(); grpc_channel_init_init(); grpc_register_tracer("api", &grpc_api_trace); grpc_register_tracer("channel", &grpc_trace_channel); grpc_register_tracer("connectivity_state", &grpc_connectivity_state_trace); grpc_register_tracer("channel_stack_builder", &grpc_trace_channel_stack_builder); grpc_register_tracer("http1", &grpc_http1_trace); grpc_register_tracer("compression", &grpc_compression_trace); grpc_register_tracer("op_failure", &grpc_trace_operation_failures); grpc_security_pre_init(); grpc_iomgr_init(); grpc_executor_init(); gpr_timers_global_init(); grpc_cq_global_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(); } gpr_mu_unlock(&g_init_mu); GRPC_API_TRACE("grpc_init(void)", 0, ()); }
static void test_code(void) { /* iomgr.h */ grpc_iomgr_init(); grpc_iomgr_shutdown(); /* closure.h */ grpc_closure closure; closure.cb = NULL; closure.cb_arg = NULL; closure.next_data.scratch = 0; grpc_closure_list closure_list = GRPC_CLOSURE_LIST_INIT; closure_list.head = NULL; closure_list.tail = NULL; grpc_closure_init(&closure, NULL, NULL); grpc_closure_create(NULL, NULL); grpc_closure_list_move(NULL, NULL); grpc_closure_list_append(NULL, NULL, GRPC_ERROR_CREATE("Foo")); grpc_closure_list_empty(closure_list); /* exec_ctx.h */ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; grpc_exec_ctx_flush(&exec_ctx); grpc_exec_ctx_finish(&exec_ctx); grpc_exec_ctx_sched(&exec_ctx, &closure, GRPC_ERROR_CREATE("Foo"), NULL); grpc_exec_ctx_enqueue_list(&exec_ctx, &closure_list, NULL); /* endpoint.h */ grpc_endpoint endpoint; grpc_endpoint_vtable vtable = {grpc_endpoint_read, grpc_endpoint_write, grpc_endpoint_get_workqueue, grpc_endpoint_add_to_pollset, grpc_endpoint_add_to_pollset_set, grpc_endpoint_shutdown, grpc_endpoint_destroy, grpc_endpoint_get_resource_user, grpc_endpoint_get_peer}; endpoint.vtable = &vtable; grpc_endpoint_read(&exec_ctx, &endpoint, NULL, NULL); grpc_endpoint_get_peer(&endpoint); grpc_endpoint_write(&exec_ctx, &endpoint, NULL, NULL); grpc_endpoint_shutdown(&exec_ctx, &endpoint); grpc_endpoint_destroy(&exec_ctx, &endpoint); grpc_endpoint_add_to_pollset(&exec_ctx, &endpoint, NULL); grpc_endpoint_add_to_pollset_set(&exec_ctx, &endpoint, NULL); /* executor.h */ grpc_executor_init(); grpc_executor_push(&closure, GRPC_ERROR_CREATE("Phi")); grpc_executor_shutdown(); /* pollset.h */ grpc_pollset_size(); grpc_pollset_init(NULL, NULL); grpc_pollset_shutdown(NULL, NULL, NULL); grpc_pollset_reset(NULL); grpc_pollset_destroy(NULL); GRPC_ERROR_UNREF(grpc_pollset_work(NULL, NULL, NULL, gpr_now(GPR_CLOCK_REALTIME), gpr_now(GPR_CLOCK_MONOTONIC))); GRPC_ERROR_UNREF(grpc_pollset_kick(NULL, NULL)); }
static void test_code(void) { /* iomgr.h */ grpc_iomgr_init(); grpc_iomgr_shutdown(); /* closure.h */ grpc_closure closure; closure.cb = NULL; closure.cb_arg = NULL; closure.final_data = 0; grpc_closure_list closure_list = GRPC_CLOSURE_LIST_INIT; closure_list.head = NULL; closure_list.tail = NULL; grpc_closure_init(&closure, NULL, NULL); grpc_closure_create(NULL, NULL); grpc_closure_list_move(NULL, NULL); grpc_closure_list_add(NULL, NULL, true); bool x = grpc_closure_list_empty(closure_list); grpc_closure_next(&closure); /* exec_ctx.h */ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; grpc_exec_ctx_flush(&exec_ctx); grpc_exec_ctx_finish(&exec_ctx); grpc_exec_ctx_enqueue(&exec_ctx, &closure, x, NULL); grpc_exec_ctx_enqueue_list(&exec_ctx, &closure_list, NULL); /* endpoint.h */ grpc_endpoint endpoint; grpc_endpoint_vtable vtable = { grpc_endpoint_read, grpc_endpoint_write, grpc_endpoint_add_to_pollset, grpc_endpoint_add_to_pollset_set, grpc_endpoint_shutdown, grpc_endpoint_destroy, grpc_endpoint_get_peer}; endpoint.vtable = &vtable; grpc_endpoint_read(&exec_ctx, &endpoint, NULL, NULL); grpc_endpoint_get_peer(&endpoint); grpc_endpoint_write(&exec_ctx, &endpoint, NULL, NULL); grpc_endpoint_shutdown(&exec_ctx, &endpoint); grpc_endpoint_destroy(&exec_ctx, &endpoint); grpc_endpoint_add_to_pollset(&exec_ctx, &endpoint, NULL); grpc_endpoint_add_to_pollset_set(&exec_ctx, &endpoint, NULL); /* executor.h */ grpc_executor_init(); grpc_executor_enqueue(&closure, x); grpc_executor_shutdown(); /* pollset.h */ grpc_pollset_size(); grpc_pollset_init(NULL, NULL); grpc_pollset_shutdown(NULL, NULL, NULL); grpc_pollset_reset(NULL); grpc_pollset_destroy(NULL); grpc_pollset_work(NULL, NULL, NULL, gpr_now(GPR_CLOCK_REALTIME), gpr_now(GPR_CLOCK_MONOTONIC)); grpc_pollset_kick(NULL, NULL); }