#undef _FORTIFY_SOURCE
/* This must be the first #include file */
-#include "async_locl.h"
+#include "async_local.h"
#include <openssl/err.h>
-#include "internal/cryptlib_int.h"
+#include "crypto/cryptlib.h"
#include <string.h>
#define ASYNC_JOB_RUNNING 0
{
async_ctx *nctx;
- if (!ossl_init_thread_start(NULL, async_delete_thread_state))
+ if (!ossl_init_thread_start(NULL, NULL, async_delete_thread_state))
return NULL;
nctx = OPENSSL_malloc(sizeof(*nctx));
int (*func)(void *), void *args, size_t size)
{
async_ctx *ctx;
+ OPENSSL_CTX *libctx;
if (!OPENSSL_init_crypto(OPENSSL_INIT_ASYNC, NULL))
return ASYNC_ERR;
if (ctx->currjob->status == ASYNC_JOB_PAUSED) {
ctx->currjob = *job;
+ /*
+ * Restore the default libctx to what it was the last time the
+ * fibre ran
+ */
+ libctx = OPENSSL_CTX_set0_default(ctx->currjob->libctx);
/* Resume previous job */
if (!async_fibre_swapcontext(&ctx->dispatcher,
&ctx->currjob->fibrectx, 1)) {
ASYNC_R_FAILED_TO_SWAP_CONTEXT);
goto err;
}
+ /*
+ * In case the fibre changed the default libctx we set it back
+ * again to what it was originally, and remember what it had
+ * been changed to.
+ */
+ ctx->currjob->libctx = OPENSSL_CTX_set0_default(libctx);
continue;
}
ctx->currjob->func = func;
ctx->currjob->waitctx = wctx;
+ libctx = openssl_ctx_get_concrete(NULL);
if (!async_fibre_swapcontext(&ctx->dispatcher,
&ctx->currjob->fibrectx, 1)) {
ASYNCerr(ASYNC_F_ASYNC_START_JOB, ASYNC_R_FAILED_TO_SWAP_CONTEXT);
goto err;
}
+ /*
+ * In case the fibre changed the default libctx we set it back again
+ * to what it was, and remember what it had been changed to.
+ */
+ ctx->currjob->libctx = OPENSSL_CTX_set0_default(libctx);
}
err:
{
ASYNC_JOB *job;
- if (!pool || !pool->jobs)
+ if (pool == NULL || pool->jobs == NULL)
return;
do {
if (!OPENSSL_init_crypto(OPENSSL_INIT_ASYNC, NULL))
return 0;
- if (!ossl_init_thread_start(NULL, async_delete_thread_state))
+ if (!ossl_init_thread_start(NULL, NULL, async_delete_thread_state))
return 0;
pool = OPENSSL_zalloc(sizeof(*pool));