53 #define N_SYS_STATUS 128
67 memset(status, 0,
sizeof(*status));
68 status->initialized =
false;
88 for (
unsigned i = 0; i < n_tor_subsystems; ++i) {
91 fprintf(stderr,
"BUG: Subsystem %s (at %u) has an invalid level %d. "
92 "It is supposed to be between %d and %d (inclusive).\n",
94 raw_assert_unreached_msg(
"There is a bug in subsystem_list.c");
96 if (sys->
level < last_level) {
97 fprintf(stderr,
"BUG: Subsystem %s (at #%u) is in the wrong position. "
98 "Its level is %d; but the previous subsystem's level was %d.\n",
100 raw_assert_unreached_msg(
"There is a bug in subsystem_list.c");
104 last_level = sys->
level;
128 for (
unsigned i = 0; i < n_tor_subsystems; ++i) {
132 if (sys->
level > target_level)
145 fprintf(stderr,
"BUG: subsystem %s (at %u) initialization failed.\n",
147 raw_assert_unreached_msg(
"A subsystem couldn't be initialized.");
163 for (
unsigned i = 0; i < n_tor_subsystems; ++i) {
167 if (sys->
level > target_level)
181 fprintf(stderr,
"BUG: subsystem %s (at %u) could not connect to "
182 "publish/subscribe system.", sys->
name, sys->
level);
183 raw_assert_unreached_msg(
"A subsystem couldn't be connected.");
217 for (
int i = (
int)n_tor_subsystems - 1; i >= 0; --i) {
221 if (sys->
level <= target_level)
241 for (
int i = (
int)n_tor_subsystems - 1; i >= 0; --i) {
262 for (
unsigned i = 0; i < n_tor_subsystems; ++i) {
283 for (
int i = (
int)n_tor_subsystems - 1; i >= 0; --i) {
303 for (
unsigned i = 0; i < n_tor_subsystems; ++i) {
305 printf(
"% 4d\t%16s\t%s\n", sys->
level, sys->
name,
321 for (
unsigned i = 0; i < n_tor_subsystems; ++i) {
326 log_debug(
LD_CONFIG,
"Added options format for %s with index %d",
327 sys->
name, options_idx);
344 for (
unsigned i = 0; i < n_tor_subsystems; ++i) {
349 log_debug(
LD_CONFIG,
"Added state format for %s with index %d",
350 sys->
name, state_idx);
356 #ifdef TOR_UNIT_TESTS
364 for (
unsigned i = 0; i < n_tor_subsystems; ++i) {
382 int i = subsys_get_idx(sys);
398 int i = subsys_get_idx(sys);
415 for (
unsigned i = 0; i < n_tor_subsystems; ++i) {
422 log_err(
LD_CONFIG,
"Error when handling option for %s; "
423 "cannot proceed.", sys->
name);
439 for (
unsigned i = 0; i < n_tor_subsystems; ++i) {
446 log_err(
LD_CONFIG,
"Error when handling state for %s; "
447 "cannot proceed.", sys->
name);
464 for (
unsigned i = 0; i < n_tor_subsystems; ++i) {
471 log_warn(
LD_CONFIG,
"Error when flushing state to state object for %s",
void * config_mgr_get_obj_mutable(const config_mgr_t *mgr, void *toplevel, int idx)
int config_mgr_add_format(config_mgr_t *mgr, const config_format_t *fmt)
Header for dispatch_naming.c.
Headers for util_malloc.c.
Types used for messages in the dispatcher code.
pubsub_connector_t * pubsub_connector_for_subsystem(pubsub_builder_t *builder, subsys_id_t subsys)
Header used for constructing the OO publish-subscribe facility.
struct pubsub_builder_t pubsub_builder_t
#define pubsub_connector_free(c)
Header for functions that add relationships to a pubsub builder.
struct pubsub_connector_t pubsub_connector_t
int(* flush_state)(void *)
const struct config_format_t * options_format
void(* thread_cleanup)(void)
int(* set_options)(void *)
int(* add_pubsub)(struct pubsub_connector_t *)
const struct config_format_t * state_format
int subsystems_set_options(const config_mgr_t *mgr, struct or_options_t *options)
void subsystems_prefork(void)
int subsystems_add_pubsub_upto(pubsub_builder_t *builder, int target_level)
int subsystems_add_pubsub(pubsub_builder_t *builder)
int subsystems_register_state_formats(config_mgr_t *mgr)
static subsys_status_t sys_status[N_SYS_STATUS]
static bool subsystem_array_validated
int subsystems_set_state(const config_mgr_t *mgr, struct or_state_t *state)
static void check_and_setup(void)
void subsystems_shutdown(void)
void subsystems_postfork(void)
int subsystems_init_upto(int target_level)
void subsystems_dump_list(void)
int subsystems_flush_state(const config_mgr_t *mgr, struct or_state_t *state)
int subsystems_register_options_formats(config_mgr_t *mgr)
static void subsys_status_clear(subsys_status_t *status)
void subsystems_shutdown_downto(int target_level)
int subsystems_init(void)
void subsystems_thread_cleanup(void)
const struct subsys_fns_t * tor_subsystems[]
Macros to manage assertions, fatal and non-fatal.