Data Fields
subsys_fns_t Struct Reference

#include <subsys.h>

Data Fields

const char * name
bool supported
int level
int(* initialize )(void)
int(* add_pubsub )(struct dispatch_connector_t *)
void(* prefork )(void)
void(* postfork )(void)
void(* thread_cleanup )(void)
void(* shutdown )(void)

Detailed Description

A subsystem is a part of Tor that is initialized, shut down, configured, and connected to other parts of Tor.

All callbacks are optional – if a callback is set to NULL, the subsystem manager will treat it as a no-op.

You should use c99 named-field initializers with this structure: we will be adding more fields, often in the middle of the structure.

Definition at line 23 of file subsys.h.

Field Documentation

◆ add_pubsub

int(* subsys_fns_t::add_pubsub) (struct dispatch_connector_t *)

Connect a subsystem to the message dispatch system.

Definition at line 61 of file subsys.h.

◆ initialize

int(* subsys_fns_t::initialize) (void)

Initialize any global components of this subsystem.

This function MAY rely on any lower-level subsystem being initialized.

This function MUST NOT rely on any runtime configuration information; it is only for global state or pre-configuration state.

(If you need to do any setup that depends on configuration, you'll need to declare a configuration callback. (Not yet designed))

This function MUST NOT have any parts that can fail.

Definition at line 56 of file subsys.h.

◆ level

int subsys_fns_t::level

The 'initialization level' for the subsystem. It should run from -100 through +100. The subsystems are initialized from lowest level to highest, and shut down from highest level to lowest.

Definition at line 41 of file subsys.h.

Referenced by memory_level().

◆ name

const char* subsys_fns_t::name

The name of this subsystem. It should be a programmer-readable identifier.

Definition at line 28 of file subsys.h.

◆ postfork

void(* subsys_fns_t::postfork) (void)

Perform any necessary post-fork setup. This function may not fail.

Definition at line 71 of file subsys.h.

◆ prefork

void(* subsys_fns_t::prefork) (void)

Perform any necessary pre-fork cleanup. This function may not fail.

Definition at line 66 of file subsys.h.

◆ shutdown

void(* subsys_fns_t::shutdown) (void)

Free all resources held by this subsystem.

This function is not allowed to fail.

Definition at line 84 of file subsys.h.

◆ supported

bool subsys_fns_t::supported

Whether this subsystem is supported – that is, whether it is compiled into Tor. For most subsystems, this should be true.

Definition at line 34 of file subsys.h.

◆ thread_cleanup

void(* subsys_fns_t::thread_cleanup) (void)

Free any thread-local resources held by this subsystem. Called before the thread exits.

Definition at line 77 of file subsys.h.

The documentation for this struct was generated from the following file: