diff options
author | Nick Mathewson <nickm@torproject.org> | 2018-11-09 11:56:26 -0500 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2018-11-09 11:56:26 -0500 |
commit | 60d10812368458cb88aa9f9d628c49766d4bb490 (patch) | |
tree | c435c3ad0fa8bfd060c5032206c30b6787410aa5 /src/app/main/subsysmgr.c | |
parent | ba722e47995e106b46d848263638fa3009687cd9 (diff) | |
download | tor-60d10812368458cb88aa9f9d628c49766d4bb490.tar.gz tor-60d10812368458cb88aa9f9d628c49766d4bb490.zip |
Log before performing a subsystem operation
Diffstat (limited to 'src/app/main/subsysmgr.c')
-rw-r--r-- | src/app/main/subsysmgr.c | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/src/app/main/subsysmgr.c b/src/app/main/subsysmgr.c index 05803ee946..abd2edd10b 100644 --- a/src/app/main/subsysmgr.c +++ b/src/app/main/subsysmgr.c @@ -7,6 +7,8 @@ #include "app/main/subsysmgr.h" #include "lib/err/torerr.h" +#include "lib/log/log.h" + #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -85,8 +87,13 @@ subsystems_init_upto(int target_level) if (sys_initialized[i]) continue; int r = 0; - if (sys->initialize) + if (sys->initialize) { + // Note that the logging subsystem is designed so that it does no harm + // to log a message in an uninitialized state. These messages will be + // discarded for now, however. + log_debug(LD_GENERAL, "Initializing %s", sys->name); r = sys->initialize(); + } if (r < 0) { fprintf(stderr, "BUG: subsystem %s (at %u) initialization failed.\n", sys->name, i); @@ -123,8 +130,10 @@ subsystems_shutdown_downto(int target_level) break; if (! sys_initialized[i]) continue; - if (sys->shutdown) + if (sys->shutdown) { + log_debug(LD_GENERAL, "Shutting down %s", sys->name); sys->shutdown(); + } sys_initialized[i] = false; } } @@ -143,8 +152,10 @@ subsystems_prefork(void) continue; if (! sys_initialized[i]) continue; - if (sys->prefork) + if (sys->prefork) { + log_debug(LD_GENERAL, "Pre-fork: %s", sys->name); sys->prefork(); + } } } @@ -162,13 +173,15 @@ subsystems_postfork(void) continue; if (! sys_initialized[i]) continue; - if (sys->postfork) + if (sys->postfork) { + log_debug(LD_GENERAL, "Post-fork: %s", sys->name); sys->postfork(); + } } } /** - * Run thread-clanup code on all subsystems that declare any + * Run thread-cleanup code on all subsystems that declare any **/ void subsystems_thread_cleanup(void) @@ -181,7 +194,9 @@ subsystems_thread_cleanup(void) continue; if (! sys_initialized[i]) continue; - if (sys->thread_cleanup) + if (sys->thread_cleanup) { + log_debug(LD_GENERAL, "Thread cleanup: %s", sys->name); sys->thread_cleanup(); + } } } |