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

[tor-commits] [tor/master] Make tortls use the subsystems interface



commit 32b23a4c40880591ecadab59f932f4a4c1e7560a
Author: Nick Mathewson <nickm@xxxxxxxxxxxxxx>
Date:   Fri Nov 2 18:46:35 2018 -0400

    Make tortls use the subsystems interface
    
    This one only needs a shutdown right now.
---
 src/app/main/main.c           |  1 -
 src/app/main/subsystem_list.c |  2 ++
 src/lib/tls/.may_include      |  1 +
 src/lib/tls/include.am        |  1 +
 src/lib/tls/tortls.c          |  8 ++++++++
 src/lib/tls/tortls_sys.h      | 14 ++++++++++++++
 6 files changed, 26 insertions(+), 1 deletion(-)

diff --git a/src/app/main/main.c b/src/app/main/main.c
index 6240609ee..4dedae9c0 100644
--- a/src/app/main/main.c
+++ b/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
diff --git a/src/app/main/subsystem_list.c b/src/app/main/subsystem_list.c
index e47b05da1..62c87005c 100644
--- a/src/app/main/subsystem_list.c
+++ b/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);
diff --git a/src/lib/tls/.may_include b/src/lib/tls/.may_include
index 2840e590b..79301bc31 100644
--- a/src/lib/tls/.may_include
+++ b/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
 
diff --git a/src/lib/tls/include.am b/src/lib/tls/include.am
index a664b29fb..1817739ee 100644
--- a/src/lib/tls/include.am
+++ b/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
diff --git a/src/lib/tls/tortls.c b/src/lib/tls/tortls.c
index 56f70bc37..fdeea9e0d 100644
--- a/src/lib/tls/tortls.c
+++ b/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
+};
diff --git a/src/lib/tls/tortls_sys.h b/src/lib/tls/tortls_sys.h
new file mode 100644
index 000000000..fd909f601
--- /dev/null
+++ b/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) */



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