tor

The Tor anonymity network
git clone https://git.dasho.dev/tor.git
Log | Files | Refs | README | LICENSE

evloop_sys.c (1084B)


      1 /* Copyright (c) 2001 Matej Pfajfar.
      2 * Copyright (c) 2001-2004, Roger Dingledine.
      3 * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
      4 * Copyright (c) 2007-2021, The Tor Project, Inc. */
      5 /* See LICENSE for licensing information */
      6 
      7 /**
      8 * @file evloop_sys.c
      9 * @brief Subsystem definition for the event loop module
     10 **/
     11 
     12 #include "orconfig.h"
     13 #include "lib/subsys/subsys.h"
     14 #include "lib/evloop/compat_libevent.h"
     15 #include "lib/evloop/evloop_sys.h"
     16 #include "lib/log/log.h"
     17 
     18 static int
     19 subsys_evloop_initialize(void)
     20 {
     21  if (tor_init_libevent_rng() < 0) {
     22    log_warn(LD_NET, "Problem initializing libevent RNG.");
     23    return -1;
     24  }
     25  return 0;
     26 }
     27 
     28 static void
     29 subsys_evloop_postfork(void)
     30 {
     31 #ifdef TOR_UNIT_TESTS
     32  tor_libevent_postfork();
     33 #endif
     34 }
     35 
     36 static void
     37 subsys_evloop_shutdown(void)
     38 {
     39  tor_libevent_free_all();
     40 }
     41 
     42 const struct subsys_fns_t sys_evloop = {
     43  .name = "evloop",
     44  SUBSYS_DECLARE_LOCATION(),
     45  .supported = true,
     46  .level = -20,
     47  .initialize = subsys_evloop_initialize,
     48  .shutdown = subsys_evloop_shutdown,
     49  .postfork = subsys_evloop_postfork,
     50 };