Commit 175153a3 authored by Nick Mathewson's avatar Nick Mathewson 🦀
Browse files

Make initialization for the "err" library into a subsystem.

parent 6e7ff8cb
Loading
Loading
Loading
Loading
+0 −10
Original line number Diff line number Diff line
@@ -69,7 +69,6 @@
#include "lib/container/buffers.h"
#include "lib/crypt_ops/crypto_rand.h"
#include "lib/crypt_ops/crypto_s2k.h"
#include "lib/err/backtrace.h"
#include "lib/geoip/geoip.h"

#include "lib/process/waitpid.h"
@@ -822,7 +821,6 @@ tor_free_all(int postfork)
  if (!postfork) {
    escaped(NULL);
    esc_router_info(NULL);
    clean_up_backtrace_handler();
    logs_free_all(); /* free log strings. do this last so logs keep working. */
  }
}
@@ -1419,14 +1417,6 @@ tor_run_main(const tor_main_configuration_t *tor_cfg)
#endif /* !defined(_WIN64) */
#endif /* defined(_WIN32) */

  {
    int bt_err = configure_backtrace_handler(get_version());
    if (bt_err < 0) {
      log_warn(LD_BUG, "Unable to install backtrace handler: %s",
               strerror(-bt_err));
    }
  }

#ifdef EVENT_SET_MEM_FUNCTIONS_IMPLEMENTED
  event_set_mem_functions(tor_malloc_, tor_realloc_, tor_free_);
#endif
+3 −1
Original line number Diff line number Diff line
@@ -8,13 +8,15 @@
#include "lib/cc/compat_compiler.h"
#include "lib/cc/torint.h"

#include "lib/err/torerr_sys.h"

#include <stddef.h>

/**
 * Global list of the subsystems in Tor, in the order of their initialization.
 **/
const subsys_fns_t *tor_subsystems[] = {
   NULL // placeholder.
  &sys_torerr,
};

const unsigned n_tor_subsystems = ARRAY_LENGTH(tor_subsystems);
+2 −0
Original line number Diff line number Diff line
orconfig.h
lib/cc/*.h
lib/err/*.h
lib/subsys/*.h
lib/version/*.h
 No newline at end of file
+5 −3
Original line number Diff line number Diff line
@@ -7,7 +7,8 @@ endif

src_lib_libtor_err_a_SOURCES =			\
	src/lib/err/backtrace.c			\
	src/lib/err/torerr.c
	src/lib/err/torerr.c			\
	src/lib/err/torerr_sys.c

src_lib_libtor_err_testing_a_SOURCES = \
	$(src_lib_libtor_err_a_SOURCES)
@@ -16,4 +17,5 @@ src_lib_libtor_err_testing_a_CFLAGS = $(AM_CFLAGS) $(TEST_CFLAGS)

noinst_HEADERS +=					\
	src/lib/err/backtrace.h				\
	src/lib/err/torerr.h
	src/lib/err/torerr.h				\
	src/lib/err/torerr_sys.h
+10 −0
Original line number Diff line number Diff line
@@ -122,6 +122,16 @@ tor_log_set_sigsafe_err_fds(const int *fds, int n)
  n_sigsafe_log_fds = n;
}

/**
 * Reset the list of emergency error fds to its default.
 */
void
tor_log_reset_sigsafe_err_fds(void)
{
  int fds[] = { STDERR_FILENO };
  tor_log_set_sigsafe_err_fds(fds, 1);
}

/**
 * Set the granularity (in ms) to use when reporting fatal errors outside
 * the logging system.
Loading