aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2018-11-02 18:46:35 -0400
committerNick Mathewson <nickm@torproject.org>2018-11-05 09:22:02 -0500
commit32b23a4c40880591ecadab59f932f4a4c1e7560a (patch)
tree49e041271aef000cd3b2264909905bed1ee026d2
parent019a044e5e6586fb42a171cb98aea15a72bd5a13 (diff)
downloadtor-32b23a4c40880591ecadab59f932f4a4c1e7560a.tar.gz
tor-32b23a4c40880591ecadab59f932f4a4c1e7560a.zip
Make tortls use the subsystems interface
This one only needs a shutdown right now.
-rw-r--r--src/app/main/main.c1
-rw-r--r--src/app/main/subsystem_list.c2
-rw-r--r--src/lib/tls/.may_include1
-rw-r--r--src/lib/tls/include.am1
-rw-r--r--src/lib/tls/tortls.c8
-rw-r--r--src/lib/tls/tortls_sys.h14
6 files changed, 26 insertions, 1 deletions
diff --git a/src/app/main/main.c b/src/app/main/main.c
index 6240609ee6..4dedae9c0c 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 e47b05da15..62c87005c6 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 2840e590b8..79301bc318 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 a664b29fb2..1817739eef 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 56f70bc371..fdeea9e0d4 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 0000000000..fd909f6019
--- /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) */