|
|
@ -21,7 +21,6 @@ |
|
|
|
#include "src/core/lib/surface/init.h" |
|
|
|
#include "src/core/lib/surface/init.h" |
|
|
|
|
|
|
|
|
|
|
|
#include <limits.h> |
|
|
|
#include <limits.h> |
|
|
|
#include <stdint.h> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "absl/base/thread_annotations.h" |
|
|
|
#include "absl/base/thread_annotations.h" |
|
|
|
|
|
|
|
|
|
|
@ -57,8 +56,9 @@ |
|
|
|
#include "src/core/lib/surface/channel_stack_type.h" |
|
|
|
#include "src/core/lib/surface/channel_stack_type.h" |
|
|
|
#include "src/core/lib/surface/init_internally.h" |
|
|
|
#include "src/core/lib/surface/init_internally.h" |
|
|
|
|
|
|
|
|
|
|
|
/* (generated) built in registry of plugins */ |
|
|
|
// Remnants of the old plugin system
|
|
|
|
extern void grpc_register_built_in_plugins(void); |
|
|
|
void grpc_resolver_dns_ares_init(void); |
|
|
|
|
|
|
|
void grpc_resolver_dns_ares_shutdown(void); |
|
|
|
|
|
|
|
|
|
|
|
#define MAX_PLUGINS 128 |
|
|
|
#define MAX_PLUGINS 128 |
|
|
|
|
|
|
|
|
|
|
@ -123,7 +123,6 @@ static void do_basic_init(void) { |
|
|
|
gpr_log_verbosity_init(); |
|
|
|
gpr_log_verbosity_init(); |
|
|
|
g_init_mu = new grpc_core::Mutex(); |
|
|
|
g_init_mu = new grpc_core::Mutex(); |
|
|
|
g_shutting_down_cv = new grpc_core::CondVar(); |
|
|
|
g_shutting_down_cv = new grpc_core::CondVar(); |
|
|
|
grpc_register_built_in_plugins(); |
|
|
|
|
|
|
|
gpr_time_init(); |
|
|
|
gpr_time_init(); |
|
|
|
grpc_core::PrintExperimentsList(); |
|
|
|
grpc_core::PrintExperimentsList(); |
|
|
|
grpc_core::Fork::GlobalInit(); |
|
|
|
grpc_core::Fork::GlobalInit(); |
|
|
@ -133,23 +132,6 @@ static void do_basic_init(void) { |
|
|
|
grpc_client_channel_global_init_backup_polling(); |
|
|
|
grpc_client_channel_global_init_backup_polling(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
typedef struct grpc_plugin { |
|
|
|
|
|
|
|
void (*init)(); |
|
|
|
|
|
|
|
void (*destroy)(); |
|
|
|
|
|
|
|
} grpc_plugin; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static grpc_plugin g_all_of_the_plugins[MAX_PLUGINS]; |
|
|
|
|
|
|
|
static int g_number_of_plugins = 0; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void grpc_register_plugin(void (*init)(void), void (*destroy)(void)) { |
|
|
|
|
|
|
|
GRPC_API_TRACE("grpc_register_plugin(init=%p, destroy=%p)", 2, |
|
|
|
|
|
|
|
((void*)(intptr_t)init, (void*)(intptr_t)destroy)); |
|
|
|
|
|
|
|
GPR_ASSERT(g_number_of_plugins != MAX_PLUGINS); |
|
|
|
|
|
|
|
g_all_of_the_plugins[g_number_of_plugins].init = init; |
|
|
|
|
|
|
|
g_all_of_the_plugins[g_number_of_plugins].destroy = destroy; |
|
|
|
|
|
|
|
g_number_of_plugins++; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void grpc_init(void) { |
|
|
|
void grpc_init(void) { |
|
|
|
gpr_once_init(&g_basic_init, do_basic_init); |
|
|
|
gpr_once_init(&g_basic_init, do_basic_init); |
|
|
|
|
|
|
|
|
|
|
@ -160,11 +142,7 @@ void grpc_init(void) { |
|
|
|
g_shutting_down_cv->SignalAll(); |
|
|
|
g_shutting_down_cv->SignalAll(); |
|
|
|
} |
|
|
|
} |
|
|
|
grpc_iomgr_init(); |
|
|
|
grpc_iomgr_init(); |
|
|
|
for (int i = 0; i < g_number_of_plugins; i++) { |
|
|
|
grpc_resolver_dns_ares_init(); |
|
|
|
if (g_all_of_the_plugins[i].init != nullptr) { |
|
|
|
|
|
|
|
g_all_of_the_plugins[i].init(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
grpc_iomgr_start(); |
|
|
|
grpc_iomgr_start(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -173,18 +151,11 @@ void grpc_init(void) { |
|
|
|
|
|
|
|
|
|
|
|
void grpc_shutdown_internal_locked(void) |
|
|
|
void grpc_shutdown_internal_locked(void) |
|
|
|
ABSL_EXCLUSIVE_LOCKS_REQUIRED(g_init_mu) { |
|
|
|
ABSL_EXCLUSIVE_LOCKS_REQUIRED(g_init_mu) { |
|
|
|
int i; |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
grpc_core::ExecCtx exec_ctx(0); |
|
|
|
grpc_core::ExecCtx exec_ctx(0); |
|
|
|
grpc_iomgr_shutdown_background_closure(); |
|
|
|
grpc_iomgr_shutdown_background_closure(); |
|
|
|
{ |
|
|
|
|
|
|
|
grpc_timer_manager_set_threading(false); // shutdown timer_manager thread
|
|
|
|
grpc_timer_manager_set_threading(false); // shutdown timer_manager thread
|
|
|
|
for (i = g_number_of_plugins; i >= 0; i--) { |
|
|
|
grpc_resolver_dns_ares_shutdown(); |
|
|
|
if (g_all_of_the_plugins[i].destroy != nullptr) { |
|
|
|
|
|
|
|
g_all_of_the_plugins[i].destroy(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
grpc_event_engine::experimental::ResetDefaultEventEngine(); |
|
|
|
grpc_event_engine::experimental::ResetDefaultEventEngine(); |
|
|
|
grpc_iomgr_shutdown(); |
|
|
|
grpc_iomgr_shutdown(); |
|
|
|
} |
|
|
|
} |
|
|
|