aboutsummaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2018-11-02 18:00:56 -0400
committerNick Mathewson <nickm@torproject.org>2018-11-05 09:22:02 -0500
commitcad61f0f6de48c6eab6e811a081f154b03de57b8 (patch)
tree9a3e3cb610f7a0315e5f3c56795176eba9ed1065 /src/lib
parent50436ccea4bd200e45196ccce7acff28f293a4de (diff)
downloadtor-cad61f0f6de48c6eab6e811a081f154b03de57b8.tar.gz
tor-cad61f0f6de48c6eab6e811a081f154b03de57b8.zip
Move prefork, postfork, and thread-exit hooks into subsys
So far, crypto is the only module that uses them, but others are likely to do so in the future.
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/crypt_ops/crypto_init.c3
-rw-r--r--src/lib/subsys/subsys.h16
2 files changed, 19 insertions, 0 deletions
diff --git a/src/lib/crypt_ops/crypto_init.c b/src/lib/crypt_ops/crypto_init.c
index cc7865ef72..a03f5eff7c 100644
--- a/src/lib/crypt_ops/crypto_init.c
+++ b/src/lib/crypt_ops/crypto_init.c
@@ -227,4 +227,7 @@ const struct subsys_fns_t sys_crypto = {
.level = -60,
.initialize = init_crypto_sys,
.shutdown = shutdown_crypto_sys,
+ .prefork = crypto_prefork,
+ .postfork = crypto_postfork,
+ .thread_cleanup = crypto_thread_cleanup,
};
diff --git a/src/lib/subsys/subsys.h b/src/lib/subsys/subsys.h
index 25451bc450..b06d67e624 100644
--- a/src/lib/subsys/subsys.h
+++ b/src/lib/subsys/subsys.h
@@ -54,6 +54,22 @@ typedef struct subsys_fns_t {
int (*add_pubsub)(struct dispatch_connector_t *);
/**
+ * Perform any necessary pre-fork cleanup. This function may not fail.
+ */
+ void (*prefork)(void);
+
+ /**
+ * Perform any necessary post-fork setup. This function may not fail.
+ */
+ void (*postfork)(void);
+
+ /**
+ * Free any thread-local resources held by this subsystem. Called before
+ * the thread exits.
+ */
+ void (*thread_cleanup)(void);
+
+ /**
* Free all resources held by this subsystem.
*
* This function is not allowed to fail.