diff options
author | Nick Mathewson <nickm@torproject.org> | 2018-11-09 11:12:12 -0500 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2018-11-09 11:12:12 -0500 |
commit | c6336727cac937b4b5ca38c9b49ed3a66ce0b579 (patch) | |
tree | 8735c6509412adbb1e8a2909cd95577e78b18074 /src/lib | |
parent | e80595f562e199049a41fdf1f3e12baced7e74d5 (diff) | |
download | tor-c6336727cac937b4b5ca38c9b49ed3a66ce0b579.tar.gz tor-c6336727cac937b4b5ca38c9b49ed3a66ce0b579.zip |
Rename subsystem callback functions to make them consistent
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/compress/compress.c | 8 | ||||
-rw-r--r-- | src/lib/crypt_ops/crypto_init.c | 32 | ||||
-rw-r--r-- | src/lib/err/torerr_sys.c | 8 | ||||
-rw-r--r-- | src/lib/log/log_sys.c | 8 | ||||
-rw-r--r-- | src/lib/net/network_sys.c | 8 | ||||
-rw-r--r-- | src/lib/process/winprocess_sys.c | 6 | ||||
-rw-r--r-- | src/lib/thread/compat_threads.c | 4 | ||||
-rw-r--r-- | src/lib/time/time_sys.c | 4 | ||||
-rw-r--r-- | src/lib/tls/tortls.c | 8 | ||||
-rw-r--r-- | src/lib/wallclock/approx_time.c | 4 |
10 files changed, 60 insertions, 30 deletions
diff --git a/src/lib/compress/compress.c b/src/lib/compress/compress.c index 0d134fd1be..6cb9bd492b 100644 --- a/src/lib/compress/compress.c +++ b/src/lib/compress/compress.c @@ -686,9 +686,15 @@ tor_compress_log_init_warnings(void) tor_zstd_warn_if_version_mismatched(); } +static int +subsys_compress_initialize(void) +{ + return tor_compress_init(); +} + const subsys_fns_t sys_compress = { .name = "compress", .supported = true, .level = -70, - .initialize = tor_compress_init, + .initialize = subsys_compress_initialize, }; diff --git a/src/lib/crypt_ops/crypto_init.c b/src/lib/crypt_ops/crypto_init.c index a03f5eff7c..4c4cc3e43b 100644 --- a/src/lib/crypt_ops/crypto_init.c +++ b/src/lib/crypt_ops/crypto_init.c @@ -207,7 +207,7 @@ tor_is_using_nss(void) } static int -init_crypto_sys(void) +subsys_crypto_initialize(void) { if (crypto_early_init() < 0) return -1; @@ -216,18 +216,36 @@ init_crypto_sys(void) } static void -shutdown_crypto_sys(void) +subsys_crypto_shutdown(void) { crypto_global_cleanup(); } +static void +subsys_crypto_prefork(void) +{ + crypto_prefork(); +} + +static void +subsys_crypto_postfork(void) +{ + crypto_postfork(); +} + +static void +subsys_crypto_thread_cleanup(void) +{ + crypto_thread_cleanup(); +} + const struct subsys_fns_t sys_crypto = { .name = "crypto", .supported = true, .level = -60, - .initialize = init_crypto_sys, - .shutdown = shutdown_crypto_sys, - .prefork = crypto_prefork, - .postfork = crypto_postfork, - .thread_cleanup = crypto_thread_cleanup, + .initialize = subsys_crypto_initialize, + .shutdown = subsys_crypto_shutdown, + .prefork = subsys_crypto_prefork, + .postfork = subsys_crypto_postfork, + .thread_cleanup = subsys_crypto_thread_cleanup, }; diff --git a/src/lib/err/torerr_sys.c b/src/lib/err/torerr_sys.c index 2f9e33e233..96bb1308a4 100644 --- a/src/lib/err/torerr_sys.c +++ b/src/lib/err/torerr_sys.c @@ -16,7 +16,7 @@ #include <stddef.h> static int -torerr_subsys_init(void) +subsys_torerr_initialize(void) { if (configure_backtrace_handler(get_version()) < 0) return -1; @@ -25,7 +25,7 @@ torerr_subsys_init(void) return 0; } static void -torerr_subsys_shutdown(void) +subsys_torerr_shutdown(void) { tor_log_reset_sigsafe_err_fds(); clean_up_backtrace_handler(); @@ -35,6 +35,6 @@ const subsys_fns_t sys_torerr = { .name = "err", .level = -100, .supported = true, - .initialize = torerr_subsys_init, - .shutdown = torerr_subsys_shutdown + .initialize = subsys_torerr_initialize, + .shutdown = subsys_torerr_shutdown }; diff --git a/src/lib/log/log_sys.c b/src/lib/log/log_sys.c index 94ec97fdc1..e20f3156ca 100644 --- a/src/lib/log/log_sys.c +++ b/src/lib/log/log_sys.c @@ -13,14 +13,14 @@ #include "lib/log/log_sys.h" static int -init_logging_subsys(void) +subsys_logging_initialize(void) { init_logging(0); return 0; } static void -shutdown_logging_subsys(void) +subsys_logging_shutdown(void) { logs_free_all(); escaped(NULL); @@ -30,6 +30,6 @@ const subsys_fns_t sys_logging = { .name = "log", .supported = true, .level = -90, - .initialize = init_logging_subsys, - .shutdown = shutdown_logging_subsys, + .initialize = subsys_logging_initialize, + .shutdown = subsys_logging_shutdown, }; diff --git a/src/lib/net/network_sys.c b/src/lib/net/network_sys.c index c9d33a94d3..ac49288ee6 100644 --- a/src/lib/net/network_sys.c +++ b/src/lib/net/network_sys.c @@ -18,7 +18,7 @@ #endif static int -init_network_sys(void) +subsys_network_initialize(void) { if (network_init() < 0) return -1; @@ -27,7 +27,7 @@ init_network_sys(void) } static void -shutdown_network_sys(void) +subsys_network_shutdown(void) { #ifdef _WIN32 WSACleanup(); @@ -39,6 +39,6 @@ const subsys_fns_t sys_network = { .name = "network", .level = -90, .supported = true, - .initialize = init_network_sys, - .shutdown = shutdown_network_sys, + .initialize = subsys_network_initialize, + .shutdown = subsys_network_shutdown, }; diff --git a/src/lib/process/winprocess_sys.c b/src/lib/process/winprocess_sys.c index e00f94c915..ef66f8bfb1 100644 --- a/src/lib/process/winprocess_sys.c +++ b/src/lib/process/winprocess_sys.c @@ -19,7 +19,7 @@ #define WINPROCESS_SYS_ENABLED true static int -init_windows_process_params(void) +subsys_winprocess_initialize(void) { #ifndef HeapEnableTerminationOnCorruption #define HeapEnableTerminationOnCorruption 1 @@ -53,12 +53,12 @@ init_windows_process_params(void) } #else /* !defined(_WIN32) */ #define WINPROCESS_SYS_ENABLED false -#define init_windows_process_params NULL +#define subsys_winprocess_initialize NULL #endif /* defined(_WIN32) */ const subsys_fns_t sys_winprocess = { .name = "winprocess", .level = -100, .supported = WINPROCESS_SYS_ENABLED, - .initialize = init_windows_process_params, + .initialize = subsys_winprocess_initialize, }; diff --git a/src/lib/thread/compat_threads.c b/src/lib/thread/compat_threads.c index 3d41faa8ce..0b466da212 100644 --- a/src/lib/thread/compat_threads.c +++ b/src/lib/thread/compat_threads.c @@ -113,7 +113,7 @@ atomic_counter_exchange(atomic_counter_t *counter, size_t newval) #endif /* !defined(HAVE_WORKING_STDATOMIC) */ static int -sys_threads_initialize(void) +subsys_threads_initialize(void) { tor_threads_init(); return 0; @@ -123,5 +123,5 @@ const subsys_fns_t sys_threads = { .name = "threads", .supported = true, .level = -95, - .initialize = sys_threads_initialize, + .initialize = subsys_threads_initialize, }; diff --git a/src/lib/time/time_sys.c b/src/lib/time/time_sys.c index 2303874f29..b29ca35e69 100644 --- a/src/lib/time/time_sys.c +++ b/src/lib/time/time_sys.c @@ -12,7 +12,7 @@ #include "lib/time/compat_time.h" static int -init_time_sys(void) +subsys_time_initialize(void) { monotime_init(); return 0; @@ -22,5 +22,5 @@ const subsys_fns_t sys_time = { .name = "time", .level = -90, .supported = true, - .initialize = init_time_sys, + .initialize = subsys_time_initialize, }; diff --git a/src/lib/tls/tortls.c b/src/lib/tls/tortls.c index fdeea9e0d4..654cacacf7 100644 --- a/src/lib/tls/tortls.c +++ b/src/lib/tls/tortls.c @@ -443,8 +443,14 @@ tor_tls_verify(int severity, tor_tls_t *tls, crypto_pk_t **identity) return rv; } +static void +subsys_tortls_shutdown(void) +{ + tor_tls_free_all(); +} + const subsys_fns_t sys_tortls = { .name = "tortls", .level = -50, - .shutdown = tor_tls_free_all + .shutdown = subsys_tortls_shutdown }; diff --git a/src/lib/wallclock/approx_time.c b/src/lib/wallclock/approx_time.c index c7a7ae9bd7..0b0ef382c2 100644 --- a/src/lib/wallclock/approx_time.c +++ b/src/lib/wallclock/approx_time.c @@ -45,7 +45,7 @@ update_approx_time(time_t now) #endif /* !defined(TIME_IS_FAST) */ static int -init_wallclock_subsys(void) +subsys_wallclock_initialize(void) { update_approx_time(time(NULL)); return 0; @@ -55,5 +55,5 @@ const subsys_fns_t sys_wallclock = { .name = "wallclock", .supported = true, .level = -99, - .initialize = init_wallclock_subsys, + .initialize = subsys_wallclock_initialize, }; |