diff options
author | Nick Mathewson <nickm@torproject.org> | 2018-11-02 18:09:44 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2018-11-05 09:22:02 -0500 |
commit | 207253df8d7c040840c7f4305534e6979bfc7bf7 (patch) | |
tree | 07e10f59d86a2ec72cd0b475ecf5e501a77ba997 /src | |
parent | cad61f0f6de48c6eab6e811a081f154b03de57b8 (diff) | |
download | tor-207253df8d7c040840c7f4305534e6979bfc7bf7.tar.gz tor-207253df8d7c040840c7f4305534e6979bfc7bf7.zip |
Move monotonic time setup into a subsystem
Diffstat (limited to 'src')
-rw-r--r-- | src/app/main/main.c | 2 | ||||
-rw-r--r-- | src/app/main/subsystem_list.c | 2 | ||||
-rw-r--r-- | src/lib/time/.may_include | 1 | ||||
-rw-r--r-- | src/lib/time/include.am | 2 | ||||
-rw-r--r-- | src/lib/time/time_sys.c | 26 | ||||
-rw-r--r-- | src/lib/time/time_sys.h | 14 | ||||
-rw-r--r-- | src/test/testing_common.c | 2 |
7 files changed, 45 insertions, 4 deletions
diff --git a/src/app/main/main.c b/src/app/main/main.c index 74c3c41e5b..bb2e9f5cdb 100644 --- a/src/app/main/main.c +++ b/src/app/main/main.c @@ -1248,7 +1248,6 @@ static int run_tor_main_loop(void) { handle_signals(); - monotime_init(); timers_initialize(); initialize_mainloop_events(); @@ -1369,7 +1368,6 @@ tor_run_main(const tor_main_configuration_t *tor_cfg) init_protocol_warning_severity_level(); tor_compress_init(); - monotime_init(); int argc = tor_cfg->argc + tor_cfg->argc_owned; char **argv = tor_calloc(argc, sizeof(char*)); diff --git a/src/app/main/subsystem_list.c b/src/app/main/subsystem_list.c index dd64568226..a9189b9941 100644 --- a/src/app/main/subsystem_list.c +++ b/src/app/main/subsystem_list.c @@ -14,6 +14,7 @@ #include "lib/net/network_sys.h" #include "lib/process/winprocess_sys.h" #include "lib/thread/thread_sys.h" +#include "lib/time/time_sys.h" #include "lib/wallclock/wallclock_sys.h" #include <stddef.h> @@ -27,6 +28,7 @@ const subsys_fns_t *tor_subsystems[] = { &sys_wallclock, &sys_threads, &sys_logging, + &sys_time, &sys_network, &sys_crypto, }; diff --git a/src/lib/time/.may_include b/src/lib/time/.may_include index 2c7e37a836..40a18805ac 100644 --- a/src/lib/time/.may_include +++ b/src/lib/time/.may_include @@ -4,6 +4,7 @@ lib/cc/*.h lib/err/*.h lib/intmath/*.h lib/log/*.h +lib/subsys/*.h lib/time/*.h lib/wallclock/*.h diff --git a/src/lib/time/include.am b/src/lib/time/include.am index a3f93a3744..dae16f49ac 100644 --- a/src/lib/time/include.am +++ b/src/lib/time/include.am @@ -7,6 +7,7 @@ endif src_lib_libtor_time_a_SOURCES = \ src/lib/time/compat_time.c \ + src/lib/time/time_sys.c \ src/lib/time/tvdiff.c src_lib_libtor_time_testing_a_SOURCES = \ @@ -16,4 +17,5 @@ src_lib_libtor_time_testing_a_CFLAGS = $(AM_CFLAGS) $(TEST_CFLAGS) noinst_HEADERS += \ src/lib/time/compat_time.h \ + src/lib/time/time_sys.h \ src/lib/time/tvdiff.h diff --git a/src/lib/time/time_sys.c b/src/lib/time/time_sys.c new file mode 100644 index 0000000000..2303874f29 --- /dev/null +++ b/src/lib/time/time_sys.c @@ -0,0 +1,26 @@ +/* Copyright (c) 2018, The Tor Project, Inc. */ +/* See LICENSE for licensing information */ + +/** + * \file time_sys.c + * \brief Subsystem object for monotime setup. + **/ + +#include "orconfig.h" +#include "lib/subsys/subsys.h" +#include "lib/time/time_sys.h" +#include "lib/time/compat_time.h" + +static int +init_time_sys(void) +{ + monotime_init(); + return 0; +} + +const subsys_fns_t sys_time = { + .name = "time", + .level = -90, + .supported = true, + .initialize = init_time_sys, +}; diff --git a/src/lib/time/time_sys.h b/src/lib/time/time_sys.h new file mode 100644 index 0000000000..0f1aebc268 --- /dev/null +++ b/src/lib/time/time_sys.h @@ -0,0 +1,14 @@ +/* Copyright (c) 2018, The Tor Project, Inc. */ +/* See LICENSE for licensing information */ + +/** + * \file log_time.h + * \brief Declare subsystem object for the time module. + **/ + +#ifndef TOR_TIME_SYS_H +#define TOR_TIME_SYS_H + +extern const struct subsys_fns_t sys_time; + +#endif /* !defined(TOR_TIME_SYS_H) */ diff --git a/src/test/testing_common.c b/src/test/testing_common.c index 1362f29711..333dbc436f 100644 --- a/src/test/testing_common.c +++ b/src/test/testing_common.c @@ -257,8 +257,6 @@ main(int c, const char **v) options = options_new(); tor_compress_init(); - monotime_init(); - struct tor_libevent_cfg cfg; memset(&cfg, 0, sizeof(cfg)); tor_libevent_initialize(&cfg); |