]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
subsys: Make the subsystem init order match the module dependencies
authorteor <teor@torproject.org>
Wed, 4 Sep 2019 05:40:57 +0000 (15:40 +1000)
committerteor <teor@torproject.org>
Fri, 6 Sep 2019 06:58:53 +0000 (16:58 +1000)
Fix levels for subsystems that depend on log/err
* winprocess (security) doesn't use err:
  * call windows process security APIs as early as possible
  * init err after winprocess
  * move wallclock so it's still after err
* network and time depend on log:
  * make sure that network and time can use logging.
  * init network and time after log

Add comments explaining the module init order.

Fixes bug 31615; bugfix on 0.4.0.1-alpha.

changes/bug31615 [new file with mode: 0644]
src/lib/err/torerr_sys.c
src/lib/log/log_sys.c
src/lib/net/network_sys.c
src/lib/process/winprocess_sys.c
src/lib/thread/compat_threads.c
src/lib/time/time_sys.c
src/lib/wallclock/approx_time.c

diff --git a/changes/bug31615 b/changes/bug31615
new file mode 100644 (file)
index 0000000..49b13be
--- /dev/null
@@ -0,0 +1,5 @@
+  o Minor bugfixes (subsystems):
+    - Make the subsystem init order match the subsystem module dependencies.
+      Call windows process security APIs as early as possible. Init log before
+      network and time, so that network and time can use logging.
+      Fixes bug 31615; bugfix on 0.4.0.1-alpha.
index 3ab1b3c4e1124d75e628bc17b9be463076c59077..34f70f1f0b5d049fe1a3352079694e67c5080797 100644 (file)
@@ -33,7 +33,10 @@ subsys_torerr_shutdown(void)
 
 const subsys_fns_t sys_torerr = {
   .name = "err",
-  .level = -100,
+  /* Low-level error handling is a diagnostic feature, we want it to init
+   * right after windows process security, and shutdown last.
+   * (Security never shuts down.) */
+  .level = -99,
   .supported = true,
   .initialize = subsys_torerr_initialize,
   .shutdown = subsys_torerr_shutdown
index d1080f226428984bde3e56142fc2c097bbdbc732..826358546ab6a8e06728ccb3450b153825faa07b 100644 (file)
@@ -29,6 +29,8 @@ subsys_logging_shutdown(void)
 const subsys_fns_t sys_logging = {
   .name = "log",
   .supported = true,
+  /* Logging depends on threads, approx time, raw logging, and security.
+   * Most other lib modules depend on logging. */
   .level = -90,
   .initialize = subsys_logging_initialize,
   .shutdown = subsys_logging_shutdown,
index 9dfdb2b45aee31675a188fbc8eff3cdc5af4021d..e0a2625d7370fb5b5804ea9f4f249e7d913af048 100644 (file)
@@ -37,7 +37,9 @@ subsys_network_shutdown(void)
 
 const subsys_fns_t sys_network = {
   .name = "network",
-  .level = -90,
+  /* Network depends on logging, and a lot of other modules depend on network.
+   */
+  .level = -80,
   .supported = true,
   .initialize = subsys_network_initialize,
   .shutdown = subsys_network_shutdown,
index 1266babca8f7fbedf8b7116b46b5e6cb9270f066..407eeaaeed770591407659b40bf7bb9dd94ab82d 100644 (file)
@@ -58,6 +58,8 @@ subsys_winprocess_initialize(void)
 
 const subsys_fns_t sys_winprocess = {
   .name = "winprocess",
+  /* HeapEnableTerminationOnCorruption and setdeppolicy() are security
+   * features, we want them to run first. */
   .level = -100,
   .supported = WINPROCESS_SYS_ENABLED,
   .initialize = subsys_winprocess_initialize,
index 35cfeba64c14ba80341f7bf85041063dedbc939f..1c4a5c4e3ff02afff92f99f89871701f40efff97 100644 (file)
@@ -122,6 +122,8 @@ subsys_threads_initialize(void)
 const subsys_fns_t sys_threads = {
   .name = "threads",
   .supported = true,
+  /* Threads is used by logging, which is a diagnostic feature, we want it to
+   * init right after low-level error handling and approx time. */
   .level = -95,
   .initialize = subsys_threads_initialize,
 };
index b3feb7b46ab0731bbdb04dd161c5b47fe7700e59..8b9aa2856c20f4c92a7de576da51671f4fc5f8bd 100644 (file)
@@ -20,7 +20,9 @@ subsys_time_initialize(void)
 
 const subsys_fns_t sys_time = {
   .name = "time",
-  .level = -90,
+  /* Monotonic time depends on logging, and a lot of other modules depend on
+   * monotonic time. */
+  .level = -80,
   .supported = true,
   .initialize = subsys_time_initialize,
 };
index 7b328040264146c565ef2f94466a35d599aabc89..77eeddaf56996b6fff2565e417321a1136ecc5f4 100644 (file)
@@ -54,6 +54,8 @@ subsys_wallclock_initialize(void)
 const subsys_fns_t sys_wallclock = {
   .name = "wallclock",
   .supported = true,
-  .level = -99,
+  /* Approximate time is a diagnostic feature, we want it to init right after
+   * low-level error handling. */
+  .level = -98,
   .initialize = subsys_wallclock_initialize,
 };