#ifndef NO_FORKING
#ifdef TINYTEST_POSTFORK
+void tinytest_prefork(void);
void tinytest_postfork(void);
#else
+static void tinytest_prefork(void) { }
static void tinytest_postfork(void) { }
#endif
if (opt_verbosity>0)
printf("[forking] ");
+ tinytest_prefork();
pid = fork();
#ifdef FORK_BREAKS_GCOV
vproc_transaction_begin(0);
#endif
+ tinytest_postfork();
if (!pid) {
/* child. */
int test_r, write_r;
char b[1];
close(outcome_pipe[0]);
- tinytest_postfork();
test_r = testcase_run_bare_(testcase);
assert(0<=(int)test_r && (int)test_r<=2);
b[0] = "NYS"[test_r];
crypto_openssl_early_init();
#endif
#ifdef ENABLE_NSS
- crypto_nss_early_init();
+ crypto_nss_early_init(0);
#endif
if (crypto_seed_rng() < 0)
return 0;
}
+/** Run operations that the crypto library requires to be happy again
+ * after forking. */
+void
+crypto_prefork(void)
+{
+#ifdef ENABLE_NSS
+ crypto_nss_prefork();
+#endif
+}
+
/** Run operations that the crypto library requires to be happy again
* after forking. */
void
void crypto_thread_cleanup(void);
int crypto_global_cleanup(void);
+void crypto_prefork(void);
void crypto_postfork(void);
const char *crypto_get_library_name(void);
}
void
-crypto_nss_early_init(void)
+crypto_nss_early_init(int nss_only)
{
- PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0);
- PK11_SetPasswordFunc(nss_password_func_always_fail);
+ if (! nss_only) {
+ PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0);
+ PK11_SetPasswordFunc(nss_password_func_always_fail);
+ }
/* Eventually we should use NSS_Init() instead -- but that wants a
directory. The documentation says that we can't use this if we want
void
crypto_nss_global_cleanup(void)
+{
+ NSS_Shutdown();
+ PL_ArenaFinish();
+ PR_Cleanup();
+}
+
+void
+crypto_nss_prefork(void)
{
NSS_Shutdown();
}
void
crypto_nss_postfork(void)
{
- crypto_nss_global_cleanup();
- crypto_nss_early_init();
+ crypto_nss_early_init(1);
}
void crypto_nss_log_errors(int severity, const char *doing);
-void crypto_nss_early_init(void);
+void crypto_nss_early_init(int nss_only);
int crypto_nss_late_init(void);
void crypto_nss_global_cleanup(void);
+void crypto_nss_prefork(void);
void crypto_nss_postfork(void);
#endif
tinytest_set_test_failed_();
}
+void tinytest_prefork(void);
void tinytest_postfork(void);
void
-tinytest_postfork(void)
+tinytest_prefork(void)
{
free_pregenerated_keys();
+ crypto_prefork();
+}
+void
+tinytest_postfork(void)
+{
crypto_postfork();
init_pregenerated_keys();
}