diff options
author | Matt Caswell <matt@openssl.org> | 2015-10-06 10:25:21 +0100 |
---|---|---|
committer | Matt Caswell <matt@openssl.org> | 2015-11-20 23:34:35 +0000 |
commit | 9f078e1961d4fc798c356fa185df083f2abdb054 (patch) | |
tree | cf3fead2994b74d7f869466366d2eaf4f05538a6 /crypto/async | |
parent | 7240557b7d6a06cd7e4cd50e52fb1e62d0a750e0 (diff) |
Optimise ASYNC_CTX handling
Don't recreate a new ASYNC_CTX every time we call ASYNC_start_job() - the
same one can be used for the life of the thread. Instead we only free it
up when we call ASYNC_free_pool().
Reviewed-by: Rich Salz <rsalz@openssl.org>
Diffstat (limited to 'crypto/async')
-rw-r--r-- | crypto/async/async.c | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/crypto/async/async.c b/crypto/async/async.c index 7a4fbf5133..47f35f4f2b 100644 --- a/crypto/async/async.c +++ b/crypto/async/async.c @@ -137,7 +137,7 @@ static ASYNC_JOB *async_get_pool_job(void) { if (pool == NULL) { /* * Pool has not been initialised, so init with the defaults, i.e. - * global pool, with no max size and no pre-created jobs + * no max size and no pre-created jobs */ if (ASYNC_init_pool(0, 0) == 0) return NULL; @@ -191,7 +191,7 @@ void ASYNC_start_func(void) int ASYNC_start_job(ASYNC_JOB **job, int *ret, int (*func)(void *), void *args, size_t size) { - if(ASYNC_get_ctx() || !ASYNC_CTX_new()) { + if(!ASYNC_get_ctx() && !ASYNC_CTX_new()) { return ASYNC_ERR; } @@ -206,14 +206,13 @@ int ASYNC_start_job(ASYNC_JOB **job, int *ret, int (*func)(void *), async_release_job(ASYNC_get_ctx()->currjob); ASYNC_get_ctx()->currjob = NULL; *job = NULL; - ASYNC_CTX_free(); return ASYNC_FINISH; } if(ASYNC_get_ctx()->currjob->status == ASYNC_JOB_PAUSING) { *job = ASYNC_get_ctx()->currjob; ASYNC_get_ctx()->currjob->status = ASYNC_JOB_PAUSED; - ASYNC_CTX_free(); + ASYNC_get_ctx()->currjob = NULL; return ASYNC_PAUSE; } @@ -230,13 +229,11 @@ int ASYNC_start_job(ASYNC_JOB **job, int *ret, int (*func)(void *), async_release_job(ASYNC_get_ctx()->currjob); ASYNC_get_ctx()->currjob = NULL; *job = NULL; - ASYNC_CTX_free(); return ASYNC_ERR; } /* Start a new job */ if(!(ASYNC_get_ctx()->currjob = async_get_pool_job())) { - ASYNC_CTX_free(); return ASYNC_NO_JOBS; } @@ -245,7 +242,6 @@ int ASYNC_start_job(ASYNC_JOB **job, int *ret, int (*func)(void *), if(!ASYNC_get_ctx()->currjob->funcargs) { async_release_job(ASYNC_get_ctx()->currjob); ASYNC_get_ctx()->currjob = NULL; - ASYNC_CTX_free(); return ASYNC_ERR; } memcpy(ASYNC_get_ctx()->currjob->funcargs, args, size); @@ -263,7 +259,6 @@ err: async_release_job(ASYNC_get_ctx()->currjob); ASYNC_get_ctx()->currjob = NULL; *job = NULL; - ASYNC_CTX_free(); return ASYNC_ERR; } @@ -347,6 +342,7 @@ void ASYNC_free_pool(void) async_empty_pool(pool); async_release_pool(); + ASYNC_CTX_free(); } ASYNC_JOB *ASYNC_get_current_job(void) |