[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [tor/master] Create a relay subsystem and move the shutdown functions there



commit b394b5b2af7f38a5e66c9875d3a55be5af840933
Author: Nick Mathewson <nickm@xxxxxxxxxxxxxx>
Date:   Wed May 1 15:36:18 2019 -0400

    Create a relay subsystem and move the shutdown functions there
---
 src/app/main/shutdown.c       |  9 ---------
 src/core/include.am           |  2 ++
 src/feature/relay/relay_sys.c | 46 +++++++++++++++++++++++++++++++++++++++++++
 src/feature/relay/relay_sys.h | 17 ++++++++++++++++
 4 files changed, 65 insertions(+), 9 deletions(-)

diff --git a/src/app/main/shutdown.c b/src/app/main/shutdown.c
index c302ce455..b8de0f37d 100644
--- a/src/app/main/shutdown.c
+++ b/src/app/main/shutdown.c
@@ -47,17 +47,13 @@
 #include "feature/nodelist/nodelist.h"
 #include "feature/nodelist/routerlist.h"
 #include "feature/nodelist/routerlist.h"
-#include "feature/relay/dns.h"
 #include "feature/relay/ext_orport.h"
-#include "feature/relay/onion_queue.h"
-#include "feature/relay/routerkeys.h"
 #include "feature/rend/rendcache.h"
 #include "feature/rend/rendclient.h"
 #include "feature/stats/geoip_stats.h"
 #include "feature/stats/rephist.h"
 #include "lib/evloop/compat_libevent.h"
 #include "lib/geoip/geoip.h"
-#include "src/feature/relay/router.h"
 
 void evdns_shutdown(int);
 
@@ -127,8 +123,6 @@ tor_free_all(int postfork)
   rend_cache_free_all();
   rend_service_authorization_free_all();
   rep_hist_free_all();
-  dns_free_all();
-  clear_pending_onions();
   circuit_free_all();
   circpad_machines_free();
   entry_guards_free_all();
@@ -141,7 +135,6 @@ tor_free_all(int postfork)
   nodelist_free_all();
   microdesc_free_all();
   routerparse_free_all();
-  ext_orport_free_all();
   control_free_all();
   protover_free_all();
   bridges_free_all();
@@ -155,8 +148,6 @@ tor_free_all(int postfork)
   if (!postfork) {
     config_free_all();
     or_state_free_all();
-    router_free_all();
-    routerkeys_free_all();
     policies_free_all();
   }
   if (!postfork) {
diff --git a/src/core/include.am b/src/core/include.am
index 9493f7955..d477cceb3 100644
--- a/src/core/include.am
+++ b/src/core/include.am
@@ -137,6 +137,7 @@ LIBTOR_APP_A_SOURCES = 				\
 	src/feature/relay/dns.c			\
 	src/feature/relay/ext_orport.c		\
 	src/feature/relay/onion_queue.c		\
+	src/feature/relay/relay_sys.c		\
 	src/feature/relay/router.c		\
 	src/feature/relay/routerkeys.c		\
 	src/feature/relay/routermode.c		\
@@ -405,6 +406,7 @@ noinst_HEADERS +=					\
 	src/feature/relay/dns_structs.h			\
 	src/feature/relay/ext_orport.h			\
 	src/feature/relay/onion_queue.h			\
+	src/feature/relay/relay_sys.h			\
 	src/feature/relay/router.h			\
 	src/feature/relay/routerkeys.h			\
 	src/feature/relay/routermode.h			\
diff --git a/src/feature/relay/relay_sys.c b/src/feature/relay/relay_sys.c
new file mode 100644
index 000000000..4fdd3d358
--- /dev/null
+++ b/src/feature/relay/relay_sys.c
@@ -0,0 +1,46 @@
+/* Copyright (c) 2001 Matej Pfajfar.
+ * Copyright (c) 2001-2004, Roger Dingledine.
+ * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
+ * Copyright (c) 2007-2019, The Tor Project, Inc. */
+/* See LICENSE for licensing information */
+
+/**
+ * @file relay_sys.c
+ * @brief Subsystem definitions for the relay module.
+ **/
+
+#include "orconfig.h"
+#include "core/or/or.h"
+
+#include "feature/relay/dns.h"
+#include "feature/relay/ext_orport.h"
+#include "feature/relay/onion_queue.h"
+#include "feature/relay/relay_sys.h"
+#include "feature/relay/routerkeys.h"
+#include "feature/relay/router.h"
+
+#include "lib/subsys/subsys.h"
+
+static int
+subsys_relay_initialize(void)
+{
+  return 0;
+}
+
+static void
+subsys_relay_shutdown(void)
+{
+  dns_free_all();
+  ext_orport_free_all();
+  clear_pending_onions();
+  routerkeys_free_all();
+  router_free_all();
+}
+
+const struct subsys_fns_t sys_relay = {
+  .name = "relay",
+  .supported = true,
+  .level = 50,
+  .initialize = subsys_relay_initialize,
+  .shutdown = subsys_relay_shutdown,
+};
diff --git a/src/feature/relay/relay_sys.h b/src/feature/relay/relay_sys.h
new file mode 100644
index 000000000..32e21d90d
--- /dev/null
+++ b/src/feature/relay/relay_sys.h
@@ -0,0 +1,17 @@
+/* Copyright (c) 2001 Matej Pfajfar.
+ * Copyright (c) 2001-2004, Roger Dingledine.
+ * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
+ * Copyright (c) 2007-2019, The Tor Project, Inc. */
+/* See LICENSE for licensing information */
+
+/**
+ * @file relay_sys.h
+ * @brief Header for feature/relay/relay_sys.c
+ **/
+
+#ifndef TOR_FEATURE_RELAY_RELAY_SYS_H
+#define TOR_FEATURE_RELAY_RELAY_SYS_H
+
+extern const struct subsys_fns_t sys_relay;
+
+#endif /* !defined(TOR_FEATURE_RELAY_RELAY_SYS_H) */



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits