aboutsummaryrefslogtreecommitdiff
path: root/src/lib/crypt_ops
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/crypt_ops')
-rw-r--r--src/lib/crypt_ops/crypto_init.c10
-rw-r--r--src/lib/crypt_ops/crypto_init.h1
-rw-r--r--src/lib/crypt_ops/crypto_nss_mgt.c7
-rw-r--r--src/lib/crypt_ops/crypto_nss_mgt.h2
4 files changed, 20 insertions, 0 deletions
diff --git a/src/lib/crypt_ops/crypto_init.c b/src/lib/crypt_ops/crypto_init.c
index 7f5a63219b..b651474cf8 100644
--- a/src/lib/crypt_ops/crypto_init.c
+++ b/src/lib/crypt_ops/crypto_init.c
@@ -127,3 +127,13 @@ crypto_global_cleanup(void)
return 0;
}
+
+/** Run operations that the crypto library requires to be happy again
+ * after forking. */
+void
+crypto_postfork(void)
+{
+#ifdef ENABLE_NSS
+ crypto_nss_postfork();
+#endif
+}
diff --git a/src/lib/crypt_ops/crypto_init.h b/src/lib/crypt_ops/crypto_init.h
index e450e2d894..3e32456b5c 100644
--- a/src/lib/crypt_ops/crypto_init.h
+++ b/src/lib/crypt_ops/crypto_init.h
@@ -24,5 +24,6 @@ int crypto_global_init(int hardwareAccel,
void crypto_thread_cleanup(void);
int crypto_global_cleanup(void);
+void crypto_postfork(void);
#endif /* !defined(TOR_CRYPTO_H) */
diff --git a/src/lib/crypt_ops/crypto_nss_mgt.c b/src/lib/crypt_ops/crypto_nss_mgt.c
index 84d9f027a4..6bcaeabd5a 100644
--- a/src/lib/crypt_ops/crypto_nss_mgt.c
+++ b/src/lib/crypt_ops/crypto_nss_mgt.c
@@ -93,3 +93,10 @@ crypto_nss_global_cleanup(void)
{
NSS_Shutdown();
}
+
+void
+crypto_nss_postfork(void)
+{
+ crypto_nss_global_cleanup();
+ crypto_nss_early_init();
+}
diff --git a/src/lib/crypt_ops/crypto_nss_mgt.h b/src/lib/crypt_ops/crypto_nss_mgt.h
index 0e899bad06..c4c94f4d89 100644
--- a/src/lib/crypt_ops/crypto_nss_mgt.h
+++ b/src/lib/crypt_ops/crypto_nss_mgt.h
@@ -26,6 +26,8 @@ void crypto_nss_early_init(void);
int crypto_nss_late_init(void);
void crypto_nss_global_cleanup(void);
+
+void crypto_nss_postfork(void);
#endif
#endif /* !defined(TOR_CRYPTO_NSS_H) */