OpenCoverage

async.c

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/openssl/src/crypto/async/async.c
Source codeSwitch to Preprocessed file
LineSourceCount
1/*-
2 * Copyright 2015-2018 The OpenSSL Project Authors. All Rights Reserved.-
3 *-
4 * Licensed under the OpenSSL license (the "License"). You may not use-
5 * this file except in compliance with the License. You can obtain a copy-
6 * in the file LICENSE in the source distribution or at-
7 * https://www.openssl.org/source/license.html-
8 */-
9-
10/*-
11 * Without this we start getting longjmp crashes because it thinks we're jumping-
12 * up the stack when in fact we are jumping to an entirely different stack. The-
13 * cost of this is not having certain buffer overrun/underrun checks etc for-
14 * this source file :-(-
15 */-
16#undef _FORTIFY_SOURCE-
17-
18/* This must be the first #include file */-
19#include "async_locl.h"-
20-
21#include <openssl/err.h>-
22#include "internal/cryptlib_int.h"-
23#include <string.h>-
24-
25#define ASYNC_JOB_RUNNING 0-
26#define ASYNC_JOB_PAUSING 1-
27#define ASYNC_JOB_PAUSED 2-
28#define ASYNC_JOB_STOPPING 3-
29-
30static CRYPTO_THREAD_LOCAL ctxkey;-
31static CRYPTO_THREAD_LOCAL poolkey;-
32-
33static async_ctx *async_ctx_new(void)-
34{-
35 async_ctx *nctx;-
36-
37 if (!ossl_init_thread_start(OPENSSL_INIT_THREAD_ASYNC))
!ossl_init_thread_start(0x01)Description
TRUEnever evaluated
FALSEevaluated 5 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-5
38 return NULL;
never executed: return ((void *)0) ;
0
39-
40 nctx = OPENSSL_malloc(sizeof(*nctx));-
41 if (nctx == NULL) {
nctx == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 5 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-5
42 ASYNCerr(ASYNC_F_ASYNC_CTX_NEW, ERR_R_MALLOC_FAILURE);-
43 goto err;
never executed: goto err;
0
44 }-
45-
46 async_fibre_init_dispatcher(&nctx->dispatcher);-
47 nctx->currjob = NULL;-
48 nctx->blocked = 0;-
49 if (!CRYPTO_THREAD_set_local(&ctxkey, nctx))
!CRYPTO_THREAD...&ctxkey, nctx)Description
TRUEnever evaluated
FALSEevaluated 5 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-5
50 goto err;
never executed: goto err;
0
51-
52 return nctx;
executed 5 times by 1 test: return nctx;
Executed by:
  • libcrypto.so.1.1
5
53err:-
54 OPENSSL_free(nctx);-
55-
56 return NULL;
never executed: return ((void *)0) ;
0
57}-
58-
59async_ctx *async_get_ctx(void)-
60{-
61 return (async_ctx *)CRYPTO_THREAD_get_local(&ctxkey);
executed 58 times by 1 test: return (async_ctx *)CRYPTO_THREAD_get_local(&ctxkey);
Executed by:
  • libcrypto.so.1.1
58
62}-
63-
64static int async_ctx_free(void)-
65{-
66 async_ctx *ctx;-
67-
68 ctx = async_get_ctx();-
69-
70 if (!CRYPTO_THREAD_set_local(&ctxkey, NULL))
!CRYPTO_THREAD... ((void *)0) )Description
TRUEnever evaluated
FALSEevaluated 6 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-6
71 return 0;
never executed: return 0;
0
72-
73 OPENSSL_free(ctx);-
74-
75 return 1;
executed 6 times by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
6
76}-
77-
78static ASYNC_JOB *async_job_new(void)-
79{-
80 ASYNC_JOB *job = NULL;-
81-
82 job = OPENSSL_zalloc(sizeof(*job));-
83 if (job == NULL) {
job == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 6 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-6
84 ASYNCerr(ASYNC_F_ASYNC_JOB_NEW, ERR_R_MALLOC_FAILURE);-
85 return NULL;
never executed: return ((void *)0) ;
0
86 }-
87-
88 job->status = ASYNC_JOB_RUNNING;-
89-
90 return job;
executed 6 times by 1 test: return job;
Executed by:
  • libcrypto.so.1.1
6
91}-
92-
93static void async_job_free(ASYNC_JOB *job)-
94{-
95 if (job != NULL) {
job != ((void *)0)Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 5 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
5-6
96 OPENSSL_free(job->funcargs);-
97 async_fibre_free(&job->fibrectx);-
98 OPENSSL_free(job);-
99 }
executed 6 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
6
100}
executed 11 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
11
101-
102static ASYNC_JOB *async_get_pool_job(void) {-
103 ASYNC_JOB *job;-
104 async_pool *pool;-
105-
106 pool = (async_pool *)CRYPTO_THREAD_get_local(&poolkey);-
107 if (pool == NULL) {
pool == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 8 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-8
108 /*-
109 * Pool has not been initialised, so init with the defaults, i.e.-
110 * no max size and no pre-created jobs-
111 */-
112 if (ASYNC_init_thread(0, 0) == 0)
ASYNC_init_thread(0, 0) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
113 return NULL;
never executed: return ((void *)0) ;
0
114 pool = (async_pool *)CRYPTO_THREAD_get_local(&poolkey);-
115 }
never executed: end of block
0
116-
117 job = sk_ASYNC_JOB_pop(pool->jobs);-
118 if (job == NULL) {
job == ((void *)0)Description
TRUEevaluated 7 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 1 time by 1 test
Evaluated by:
  • libcrypto.so.1.1
1-7
119 /* Pool is empty */-
120 if ((pool->max_size != 0) && (pool->curr_size >= pool->max_size))
(pool->max_size != 0)Description
TRUEevaluated 7 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
(pool->curr_si...ool->max_size)Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 6 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-7
121 return NULL;
executed 1 time by 1 test: return ((void *)0) ;
Executed by:
  • libcrypto.so.1.1
1
122-
123 job = async_job_new();-
124 if (job != NULL) {
job != ((void *)0)Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
0-6
125 if (! async_fibre_makecontext(&job->fibrectx)) {
! async_fibre_...job->fibrectx)Description
TRUEnever evaluated
FALSEevaluated 6 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-6
126 async_job_free(job);-
127 return NULL;
never executed: return ((void *)0) ;
0
128 }-
129 pool->curr_size++;-
130 }
executed 6 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
6
131 }
executed 6 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
6
132 return job;
executed 7 times by 1 test: return job;
Executed by:
  • libcrypto.so.1.1
7
133}-
134-
135static void async_release_job(ASYNC_JOB *job) {-
136 async_pool *pool;-
137-
138 pool = (async_pool *)CRYPTO_THREAD_get_local(&poolkey);-
139 OPENSSL_free(job->funcargs);-
140 job->funcargs = NULL;-
141 sk_ASYNC_JOB_push(pool->jobs, job);-
142}
executed 7 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
7
143-
144void async_start_func(void)-
145{-
146 ASYNC_JOB *job;-
147 async_ctx *ctx = async_get_ctx();-
148-
149 while (1) {-
150 /* Run the job */-
151 job = ctx->currjob;-
152 job->ret = job->func(job->funcargs);-
153-
154 /* Stop the job */-
155 job->status = ASYNC_JOB_STOPPING;-
156 if (!async_fibre_swapcontext(&job->fibrectx,
!async_fibre_s...dispatcher, 1)Description
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-1
157 &ctx->dispatcher, 1)) {
!async_fibre_s...dispatcher, 1)Description
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-1
158 /*-
159 * Should not happen. Getting here will close the thread...can't do-
160 * much about it-
161 */-
162 ASYNCerr(ASYNC_F_ASYNC_START_FUNC, ASYNC_R_FAILED_TO_SWAP_CONTEXT);-
163 }
never executed: end of block
0
164 }
executed 1 time by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
1
165}
never executed: end of block
0
166-
167int ASYNC_start_job(ASYNC_JOB **job, ASYNC_WAIT_CTX *wctx, int *ret,-
168 int (*func)(void *), void *args, size_t size)-
169{-
170 async_ctx *ctx;-
171-
172 if (!OPENSSL_init_crypto(OPENSSL_INIT_ASYNC, NULL))
!OPENSSL_init_... ((void *)0) )Description
TRUEnever evaluated
FALSEevaluated 17 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-17
173 return ASYNC_ERR;
never executed: return 0;
0
174-
175 ctx = async_get_ctx();-
176 if (ctx == NULL)
ctx == ((void *)0)Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 12 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
5-12
177 ctx = async_ctx_new();
executed 5 times by 1 test: ctx = async_ctx_new();
Executed by:
  • libcrypto.so.1.1
5
178 if (ctx == NULL)
ctx == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 17 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-17
179 return ASYNC_ERR;
never executed: return 0;
0
180-
181 if (*job)
*jobDescription
TRUEevaluated 9 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 8 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
8-9
182 ctx->currjob = *job;
executed 9 times by 1 test: ctx->currjob = *job;
Executed by:
  • libcrypto.so.1.1
9
183-
184 for (;;) {-
185 if (ctx->currjob != NULL) {
ctx->currjob != ((void *)0)Description
TRUEevaluated 25 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 8 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
8-25
186 if (ctx->currjob->status == ASYNC_JOB_STOPPING) {
ctx->currjob->status == 3Description
TRUEevaluated 7 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 18 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
7-18
187 *ret = ctx->currjob->ret;-
188 ctx->currjob->waitctx = NULL;-
189 async_release_job(ctx->currjob);-
190 ctx->currjob = NULL;-
191 *job = NULL;-
192 return ASYNC_FINISH;
executed 7 times by 1 test: return 3;
Executed by:
  • libcrypto.so.1.1
7
193 }-
194-
195 if (ctx->currjob->status == ASYNC_JOB_PAUSING) {
ctx->currjob->status == 1Description
TRUEevaluated 9 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 9 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
9
196 *job = ctx->currjob;-
197 ctx->currjob->status = ASYNC_JOB_PAUSED;-
198 ctx->currjob = NULL;-
199 return ASYNC_PAUSE;
executed 9 times by 1 test: return 2;
Executed by:
  • libcrypto.so.1.1
9
200 }-
201-
202 if (ctx->currjob->status == ASYNC_JOB_PAUSED) {
ctx->currjob->status == 2Description
TRUEevaluated 9 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
0-9
203 ctx->currjob = *job;-
204 /* Resume previous job */-
205 if (!async_fibre_swapcontext(&ctx->dispatcher,
!async_fibre_s...->fibrectx, 1)Description
TRUEnever evaluated
FALSEevaluated 9 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-9
206 &ctx->currjob->fibrectx, 1)) {
!async_fibre_s...->fibrectx, 1)Description
TRUEnever evaluated
FALSEevaluated 9 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-9
207 ASYNCerr(ASYNC_F_ASYNC_START_JOB,-
208 ASYNC_R_FAILED_TO_SWAP_CONTEXT);-
209 goto err;
never executed: goto err;
0
210 }-
211 continue;
executed 9 times by 1 test: continue;
Executed by:
  • libcrypto.so.1.1
9
212 }-
213-
214 /* Should not happen */-
215 ASYNCerr(ASYNC_F_ASYNC_START_JOB, ERR_R_INTERNAL_ERROR);-
216 async_release_job(ctx->currjob);-
217 ctx->currjob = NULL;-
218 *job = NULL;-
219 return ASYNC_ERR;
never executed: return 0;
0
220 }-
221-
222 /* Start a new job */-
223 if ((ctx->currjob = async_get_pool_job()) == NULL)
(ctx->currjob ...== ((void *)0)Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 7 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
1-7
224 return ASYNC_NO_JOBS;
executed 1 time by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
1
225-
226 if (args != NULL) {
args != ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 7 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-7
227 ctx->currjob->funcargs = OPENSSL_malloc(size);-
228 if (ctx->currjob->funcargs == NULL) {
ctx->currjob->...== ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
229 ASYNCerr(ASYNC_F_ASYNC_START_JOB, ERR_R_MALLOC_FAILURE);-
230 async_release_job(ctx->currjob);-
231 ctx->currjob = NULL;-
232 return ASYNC_ERR;
never executed: return 0;
0
233 }-
234 memcpy(ctx->currjob->funcargs, args, size);-
235 } else {
never executed: end of block
0
236 ctx->currjob->funcargs = NULL;-
237 }
executed 7 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
7
238-
239 ctx->currjob->func = func;-
240 ctx->currjob->waitctx = wctx;-
241 if (!async_fibre_swapcontext(&ctx->dispatcher,
!async_fibre_s...->fibrectx, 1)Description
TRUEnever evaluated
FALSEevaluated 7 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-7
242 &ctx->currjob->fibrectx, 1)) {
!async_fibre_s...->fibrectx, 1)Description
TRUEnever evaluated
FALSEevaluated 7 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-7
243 ASYNCerr(ASYNC_F_ASYNC_START_JOB, ASYNC_R_FAILED_TO_SWAP_CONTEXT);-
244 goto err;
never executed: goto err;
0
245 }-
246 }
executed 7 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
7
247-
248err:
code before this statement never executed: err:
0
249 async_release_job(ctx->currjob);-
250 ctx->currjob = NULL;-
251 *job = NULL;-
252 return ASYNC_ERR;
never executed: return 0;
0
253}-
254-
255int ASYNC_pause_job(void)-
256{-
257 ASYNC_JOB *job;-
258 async_ctx *ctx = async_get_ctx();-
259-
260 if (ctx == NULL
ctx == ((void *)0)Description
TRUEevaluated 9 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 10 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
9-10
261 || ctx->currjob == NULL
ctx->currjob == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 10 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-10
262 || ctx->blocked) {
ctx->blockedDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 9 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
1-9
263 /*-
264 * Could be we've deliberately not been started within a job so this is-
265 * counted as success.-
266 */-
267 return 1;
executed 10 times by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
10
268 }-
269-
270 job = ctx->currjob;-
271 job->status = ASYNC_JOB_PAUSING;-
272-
273 if (!async_fibre_swapcontext(&job->fibrectx,
!async_fibre_s...dispatcher, 1)Description
TRUEnever evaluated
FALSEevaluated 9 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-9
274 &ctx->dispatcher, 1)) {
!async_fibre_s...dispatcher, 1)Description
TRUEnever evaluated
FALSEevaluated 9 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-9
275 ASYNCerr(ASYNC_F_ASYNC_PAUSE_JOB, ASYNC_R_FAILED_TO_SWAP_CONTEXT);-
276 return 0;
never executed: return 0;
0
277 }-
278 /* Reset counts of added and deleted fds */-
279 async_wait_ctx_reset_counts(job->waitctx);-
280-
281 return 1;
executed 9 times by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
9
282}-
283-
284static void async_empty_pool(async_pool *pool)-
285{-
286 ASYNC_JOB *job;-
287-
288 if (!pool || !pool->jobs)
!poolDescription
TRUEnever evaluated
FALSEevaluated 5 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
!pool->jobsDescription
TRUEnever evaluated
FALSEevaluated 5 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-5
289 return;
never executed: return;
0
290-
291 do {-
292 job = sk_ASYNC_JOB_pop(pool->jobs);-
293 async_job_free(job);-
294 } while (job);
executed 11 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
jobDescription
TRUEevaluated 6 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 5 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
5-11
295}
executed 5 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
5
296-
297int async_init(void)-
298{-
299 if (!CRYPTO_THREAD_init_local(&ctxkey, NULL))
!CRYPTO_THREAD... ((void *)0) )Description
TRUEnever evaluated
FALSEevaluated 4 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-4
300 return 0;
never executed: return 0;
0
301-
302 if (!CRYPTO_THREAD_init_local(&poolkey, NULL)) {
!CRYPTO_THREAD... ((void *)0) )Description
TRUEnever evaluated
FALSEevaluated 4 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-4
303 CRYPTO_THREAD_cleanup_local(&ctxkey);-
304 return 0;
never executed: return 0;
0
305 }-
306-
307 return 1;
executed 4 times by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
4
308}-
309-
310void async_deinit(void)-
311{-
312 CRYPTO_THREAD_cleanup_local(&ctxkey);-
313 CRYPTO_THREAD_cleanup_local(&poolkey);-
314}
executed 4 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
4
315-
316int ASYNC_init_thread(size_t max_size, size_t init_size)-
317{-
318 async_pool *pool;-
319 size_t curr_size = 0;-
320-
321 if (init_size > max_size) {
init_size > max_sizeDescription
TRUEnever evaluated
FALSEevaluated 5 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-5
322 ASYNCerr(ASYNC_F_ASYNC_INIT_THREAD, ASYNC_R_INVALID_POOL_SIZE);-
323 return 0;
never executed: return 0;
0
324 }-
325-
326 if (!OPENSSL_init_crypto(OPENSSL_INIT_ASYNC, NULL))
!OPENSSL_init_... ((void *)0) )Description
TRUEnever evaluated
FALSEevaluated 5 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-5
327 return 0;
never executed: return 0;
0
328-
329 if (!ossl_init_thread_start(OPENSSL_INIT_THREAD_ASYNC))
!ossl_init_thread_start(0x01)Description
TRUEnever evaluated
FALSEevaluated 5 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-5
330 return 0;
never executed: return 0;
0
331-
332 pool = OPENSSL_zalloc(sizeof(*pool));-
333 if (pool == NULL) {
pool == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 5 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-5
334 ASYNCerr(ASYNC_F_ASYNC_INIT_THREAD, ERR_R_MALLOC_FAILURE);-
335 return 0;
never executed: return 0;
0
336 }-
337-
338 pool->jobs = sk_ASYNC_JOB_new_reserve(NULL, init_size);-
339 if (pool->jobs == NULL) {
pool->jobs == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 5 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-5
340 ASYNCerr(ASYNC_F_ASYNC_INIT_THREAD, ERR_R_MALLOC_FAILURE);-
341 OPENSSL_free(pool);-
342 return 0;
never executed: return 0;
0
343 }-
344-
345 pool->max_size = max_size;-
346-
347 /* Pre-create jobs as required */-
348 while (init_size--) {
init_size--Description
TRUEnever evaluated
FALSEevaluated 5 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-5
349 ASYNC_JOB *job;-
350 job = async_job_new();-
351 if (job == NULL || !async_fibre_makecontext(&job->fibrectx)) {
job == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
!async_fibre_m...job->fibrectx)Description
TRUEnever evaluated
FALSEnever evaluated
0
352 /*-
353 * Not actually fatal because we already created the pool, just-
354 * skip creation of any more jobs-
355 */-
356 async_job_free(job);-
357 break;
never executed: break;
0
358 }-
359 job->funcargs = NULL;-
360 sk_ASYNC_JOB_push(pool->jobs, job); /* Cannot fail due to reserve */-
361 curr_size++;-
362 }
never executed: end of block
0
363 pool->curr_size = curr_size;-
364 if (!CRYPTO_THREAD_set_local(&poolkey, pool)) {
!CRYPTO_THREAD...poolkey, pool)Description
TRUEnever evaluated
FALSEevaluated 5 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-5
365 ASYNCerr(ASYNC_F_ASYNC_INIT_THREAD, ASYNC_R_FAILED_TO_SET_POOL);-
366 goto err;
never executed: goto err;
0
367 }-
368-
369 return 1;
executed 5 times by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
5
370err:-
371 async_empty_pool(pool);-
372 sk_ASYNC_JOB_free(pool->jobs);-
373 OPENSSL_free(pool);-
374 return 0;
never executed: return 0;
0
375}-
376-
377void async_delete_thread_state(void)-
378{-
379 async_pool *pool = (async_pool *)CRYPTO_THREAD_get_local(&poolkey);-
380-
381 if (pool != NULL) {
pool != ((void *)0)Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 1 time by 1 test
Evaluated by:
  • libcrypto.so.1.1
1-5
382 async_empty_pool(pool);-
383 sk_ASYNC_JOB_free(pool->jobs);-
384 OPENSSL_free(pool);-
385 CRYPTO_THREAD_set_local(&poolkey, NULL);-
386 }
executed 5 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
5
387 async_local_cleanup();-
388 async_ctx_free();-
389}
executed 6 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
6
390-
391void ASYNC_cleanup_thread(void)-
392{-
393 if (!OPENSSL_init_crypto(OPENSSL_INIT_ASYNC, NULL))
!OPENSSL_init_... ((void *)0) )Description
TRUEnever evaluated
FALSEevaluated 5 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-5
394 return;
never executed: return;
0
395-
396 async_delete_thread_state();-
397}
executed 5 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
5
398-
399ASYNC_JOB *ASYNC_get_current_job(void)-
400{-
401 async_ctx *ctx;-
402-
403 if (!OPENSSL_init_crypto(OPENSSL_INIT_ASYNC, NULL))
!OPENSSL_init_... ((void *)0) )Description
TRUEnever evaluated
FALSEevaluated 8 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-8
404 return NULL;
never executed: return ((void *)0) ;
0
405-
406 ctx = async_get_ctx();-
407 if (ctx == NULL)
ctx == ((void *)0)Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 2 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
2-6
408 return NULL;
executed 6 times by 1 test: return ((void *)0) ;
Executed by:
  • libcrypto.so.1.1
6
409-
410 return ctx->currjob;
executed 2 times by 1 test: return ctx->currjob;
Executed by:
  • libcrypto.so.1.1
2
411}-
412-
413ASYNC_WAIT_CTX *ASYNC_get_wait_ctx(ASYNC_JOB *job)-
414{-
415 return job->waitctx;
executed 1 time by 1 test: return job->waitctx;
Executed by:
  • libcrypto.so.1.1
1
416}-
417-
418void ASYNC_block_pause(void)-
419{-
420 async_ctx *ctx;-
421-
422 if (!OPENSSL_init_crypto(OPENSSL_INIT_ASYNC, NULL))
!OPENSSL_init_... ((void *)0) )Description
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-1
423 return;
never executed: return;
0
424-
425 ctx = async_get_ctx();-
426 if (ctx == NULL || ctx->currjob == NULL) {
ctx == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • libcrypto.so.1.1
ctx->currjob == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-1
427 /*-
428 * We're not in a job anyway so ignore this-
429 */-
430 return;
never executed: return;
0
431 }-
432 ctx->blocked++;-
433}
executed 1 time by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
1
434-
435void ASYNC_unblock_pause(void)-
436{-
437 async_ctx *ctx;-
438-
439 if (!OPENSSL_init_crypto(OPENSSL_INIT_ASYNC, NULL))
!OPENSSL_init_... ((void *)0) )Description
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-1
440 return;
never executed: return;
0
441-
442 ctx = async_get_ctx();-
443 if (ctx == NULL || ctx->currjob == NULL) {
ctx == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • libcrypto.so.1.1
ctx->currjob == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-1
444 /*-
445 * We're not in a job anyway so ignore this-
446 */-
447 return;
never executed: return;
0
448 }-
449 if (ctx->blocked > 0)
ctx->blocked > 0Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
0-1
450 ctx->blocked--;
executed 1 time by 1 test: ctx->blocked--;
Executed by:
  • libcrypto.so.1.1
1
451}
executed 1 time by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
1
Source codeSwitch to Preprocessed file

Generated by Squish Coco 4.2.2