Browse Source

Make tortls use the subsystems interface

This one only needs a shutdown right now.
Nick Mathewson 5 years ago
parent
commit
32b23a4c40

+ 0 - 1
src/app/main/main.c

@@ -776,7 +776,6 @@ tor_free_all(int postfork)
     policies_free_all();
   }
   if (!postfork) {
-    tor_tls_free_all();
 #ifndef _WIN32
     tor_getpwnam(NULL);
 #endif

+ 2 - 0
src/app/main/subsystem_list.c

@@ -16,6 +16,7 @@
 #include "lib/process/winprocess_sys.h"
 #include "lib/thread/thread_sys.h"
 #include "lib/time/time_sys.h"
+#include "lib/tls/tortls_sys.h"
 #include "lib/wallclock/wallclock_sys.h"
 
 #include <stddef.h>
@@ -33,6 +34,7 @@ const subsys_fns_t *tor_subsystems[] = {
   &sys_network,
   &sys_compress,
   &sys_crypto,
+  &sys_tortls,
 };
 
 const unsigned n_tor_subsystems = ARRAY_LENGTH(tor_subsystems);

+ 1 - 0
src/lib/tls/.may_include

@@ -11,6 +11,7 @@ lib/log/*.h
 lib/malloc/*.h
 lib/net/*.h
 lib/string/*.h
+lib/subsys/*.h
 lib/testsupport/testsupport.h
 lib/tls/*.h
 

+ 1 - 0
src/lib/tls/include.am

@@ -36,5 +36,6 @@ noinst_HEADERS +=				\
 	src/lib/tls/tortls.h			\
 	src/lib/tls/tortls_internal.h		\
 	src/lib/tls/tortls_st.h			\
+	src/lib/tls/tortls_sys.h		\
 	src/lib/tls/x509.h			\
 	src/lib/tls/x509_internal.h

+ 8 - 0
src/lib/tls/tortls.c

@@ -7,6 +7,7 @@
 #define TOR_X509_PRIVATE
 #include "lib/tls/x509.h"
 #include "lib/tls/x509_internal.h"
+#include "lib/tls/tortls_sys.h"
 #include "lib/tls/tortls.h"
 #include "lib/tls/tortls_st.h"
 #include "lib/tls/tortls_internal.h"
@@ -15,6 +16,7 @@
 #include "lib/crypt_ops/crypto_rsa.h"
 #include "lib/crypt_ops/crypto_rand.h"
 #include "lib/net/socket.h"
+#include "lib/subsys/subsys.h"
 
 #ifdef _WIN32
   #include <winsock2.h>
@@ -440,3 +442,9 @@ tor_tls_verify(int severity, tor_tls_t *tls, crypto_pk_t **identity)
 
   return rv;
 }
+
+const subsys_fns_t sys_tortls = {
+  .name = "tortls",
+  .level = -50,
+  .shutdown = tor_tls_free_all
+};

+ 14 - 0
src/lib/tls/tortls_sys.h

@@ -0,0 +1,14 @@
+/* Copyright (c) 2018, The Tor Project, Inc. */
+/* See LICENSE for licensing information */
+
+/**
+ * \file tortls_sys.h
+ * \brief Declare subsystem object for the tortls module
+ **/
+
+#ifndef TOR_TORTLS_SYS_H
+#define TOR_TORTLS_SYS_H
+
+extern const struct subsys_fns_t sys_tortls;
+
+#endif /* !defined(TOR_TORTLS_SYS_H) */