Classes | Namespaces | Macros | Typedefs | Functions | Variables
init.cc File Reference
#include <grpc/support/port_platform.h>
#include "src/core/lib/surface/init.h"
#include <limits.h>
#include <stdint.h>
#include "absl/base/thread_annotations.h"
#include <grpc/fork.h>
#include <grpc/grpc.h>
#include <grpc/grpc_security.h>
#include <grpc/impl/codegen/grpc_types.h>
#include <grpc/support/log.h>
#include <grpc/support/sync.h>
#include <grpc/support/time.h>
#include "src/core/lib/channel/channel_args.h"
#include "src/core/lib/channel/channel_stack_builder.h"
#include "src/core/lib/config/core_configuration.h"
#include "src/core/lib/debug/stats.h"
#include "src/core/lib/debug/trace.h"
#include "src/core/lib/event_engine/forkable.h"
#include "src/core/lib/gprpp/fork.h"
#include "src/core/lib/gprpp/sync.h"
#include "src/core/lib/gprpp/thd.h"
#include "src/core/lib/iomgr/exec_ctx.h"
#include "src/core/lib/iomgr/executor.h"
#include "src/core/lib/iomgr/iomgr.h"
#include "src/core/lib/iomgr/timer_manager.h"
#include "src/core/lib/profiling/timers.h"
#include "src/core/lib/security/authorization/grpc_server_authz_filter.h"
#include "src/core/lib/security/credentials/credentials.h"
#include "src/core/lib/security/security_connector/security_connector.h"
#include "src/core/lib/security/transport/auth_filters.h"
#include "src/core/lib/surface/api_trace.h"
#include "src/core/lib/surface/channel_init.h"
#include "src/core/lib/surface/channel_stack_type.h"
#include "src/core/lib/surface/completion_queue.h"
Include dependency graph for init.cc:

Go to the source code of this file.

Classes

struct  grpc_plugin
 

Namespaces

 grpc_core
 

Macros

#define MAX_PLUGINS   128
 

Typedefs

typedef struct grpc_plugin grpc_plugin
 

Functions

static int g_initializations ABSL_GUARDED_BY (g_init_mu) = false
 
static void do_basic_init (void)
 
void grpc_init (void)
 
int grpc_is_initialized (void)
 
void grpc_maybe_wait_for_async_shutdown (void)
 
void grpc_register_built_in_plugins (void)
 
void grpc_register_plugin (void(*init)(void), void(*destroy)(void))
 
void grpc_shutdown (void)
 
void grpc_shutdown_blocking (void)
 
void grpc_shutdown_internal (void *)
 
void grpc_shutdown_internal_locked (void) ABSL_EXCLUSIVE_LOCKS_REQUIRED(g_init_mu)
 
static bool maybe_prepend_client_auth_filter (grpc_core::ChannelStackBuilder *builder)
 
static bool maybe_prepend_grpc_server_authz_filter (grpc_core::ChannelStackBuilder *builder)
 
static bool maybe_prepend_server_auth_filter (grpc_core::ChannelStackBuilder *builder)
 
void grpc_core::RegisterSecurityFilters (CoreConfiguration::Builder *builder)
 

Variables

static grpc_plugin g_all_of_the_plugins [MAX_PLUGINS]
 
static gpr_once g_basic_init = GPR_ONCE_INIT
 
static grpc_core::Mutexg_init_mu
 
static int g_number_of_plugins = 0
 
static grpc_core::CondVarg_shutting_down_cv
 

Macro Definition Documentation

◆ MAX_PLUGINS

#define MAX_PLUGINS   128

Definition at line 62 of file init.cc.

Typedef Documentation

◆ grpc_plugin

typedef struct grpc_plugin grpc_plugin

Function Documentation

◆ ABSL_GUARDED_BY()

static bool g_shutting_down ABSL_GUARDED_BY ( g_init_mu  ) = false
static

◆ do_basic_init()

static void do_basic_init ( void  )
static

Definition at line 119 of file init.cc.

◆ grpc_init()

void grpc_init ( void  )

Initialize the grpc library.

After it's called, a matching invocation to grpc_shutdown() is expected.

It is not safe to call any other grpc functions before calling this. (To avoid overhead, little checking is done, and some things may work. We do not warrant that they will continue to do so in future revisions of this library).

Definition at line 146 of file init.cc.

◆ grpc_is_initialized()

int grpc_is_initialized ( void  )

EXPERIMENTAL. Returns 1 if the grpc library has been initialized. TODO(ericgribkoff) Decide if this should be promoted to non-experimental as part of stabilizing the fork support API, as tracked in https://github.com/grpc/grpc/issues/15334

Definition at line 247 of file init.cc.

◆ grpc_maybe_wait_for_async_shutdown()

void grpc_maybe_wait_for_async_shutdown ( void  )

Definition at line 255 of file init.cc.

◆ grpc_register_built_in_plugins()

void grpc_register_built_in_plugins ( void  )

Definition at line 32 of file grpc_cronet_plugin_registry.cc.

◆ grpc_register_plugin()

void grpc_register_plugin ( void(*)(void)  init,
void(*)(void)  destroy 
)

Registers a plugin to be initialized and destroyed with the library.

The init and destroy functions will be invoked as part of grpc_init() and grpc_shutdown(), respectively. Note that these functions can be invoked an arbitrary number of times (and hence so will init and destroy). It is safe to pass NULL to either argument. Plugins are destroyed in the reverse order they were initialized.

Definition at line 137 of file init.cc.

◆ grpc_shutdown()

void grpc_shutdown ( void  )

Shut down the grpc library.

Before it's called, there should haven been a matching invocation to grpc_init().

The last call to grpc_shutdown will initiate cleaning up of grpc library internals, which can happen in another thread. Once the clean-up is done, no memory is used by grpc, nor are any instructions executing within the grpc library. Prior to calling, all application owned grpc objects must have been destroyed.

Definition at line 209 of file init.cc.

◆ grpc_shutdown_blocking()

void grpc_shutdown_blocking ( void  )

DEPRECATED. Recommend to use grpc_shutdown only

Definition at line 238 of file init.cc.

◆ grpc_shutdown_internal()

void grpc_shutdown_internal ( void *  )

Definition at line 198 of file init.cc.

◆ grpc_shutdown_internal_locked()

void grpc_shutdown_internal_locked ( void  )

Definition at line 174 of file init.cc.

◆ maybe_prepend_client_auth_filter()

static bool maybe_prepend_client_auth_filter ( grpc_core::ChannelStackBuilder builder)
static

Definition at line 74 of file init.cc.

◆ maybe_prepend_grpc_server_authz_filter()

static bool maybe_prepend_grpc_server_authz_filter ( grpc_core::ChannelStackBuilder builder)
static

Definition at line 90 of file init.cc.

◆ maybe_prepend_server_auth_filter()

static bool maybe_prepend_server_auth_filter ( grpc_core::ChannelStackBuilder builder)
static

Definition at line 82 of file init.cc.

Variable Documentation

◆ g_all_of_the_plugins

grpc_plugin g_all_of_the_plugins[MAX_PLUGINS]
static

Definition at line 134 of file init.cc.

◆ g_basic_init

gpr_once g_basic_init = GPR_ONCE_INIT
static

Definition at line 64 of file init.cc.

◆ g_init_mu

grpc_core::Mutex* g_init_mu
static

Definition at line 65 of file init.cc.

◆ g_number_of_plugins

int g_number_of_plugins = 0
static

Definition at line 135 of file init.cc.

◆ g_shutting_down_cv

grpc_core::CondVar* g_shutting_down_cv
static

Definition at line 71 of file init.cc.



grpc
Author(s):
autogenerated on Fri May 16 2025 03:01:20