| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/openssl/src/crypto/async/async.c |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||||||||||||||
| 2 | - | |||||||||||||||||||||||||
| 3 | - | |||||||||||||||||||||||||
| 4 | - | |||||||||||||||||||||||||
| 5 | - | |||||||||||||||||||||||||
| 6 | - | |||||||||||||||||||||||||
| 7 | - | |||||||||||||||||||||||||
| 8 | - | |||||||||||||||||||||||||
| 9 | static CRYPTO_THREAD_LOCAL ctxkey; | - | ||||||||||||||||||||||||
| 10 | static CRYPTO_THREAD_LOCAL poolkey; | - | ||||||||||||||||||||||||
| 11 | - | |||||||||||||||||||||||||
| 12 | static async_ctx *async_ctx_new(void) | - | ||||||||||||||||||||||||
| 13 | { | - | ||||||||||||||||||||||||
| 14 | async_ctx *nctx; | - | ||||||||||||||||||||||||
| 15 | - | |||||||||||||||||||||||||
| 16 | if (!ossl_init_thread_start(0x01)
| 0-5 | ||||||||||||||||||||||||
| 17 | return never executed: return ((void *)0) ;never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||
| 18 | ((void *)0) never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||
| 19 | ; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||
| 20 | - | |||||||||||||||||||||||||
| 21 | nctx = CRYPTO_malloc(sizeof(*nctx), __FILE__, 40); | - | ||||||||||||||||||||||||
| 22 | if (nctx ==
| 0-5 | ||||||||||||||||||||||||
| 23 | ((void *)0)
| 0-5 | ||||||||||||||||||||||||
| 24 | ) { | - | ||||||||||||||||||||||||
| 25 | ERR_put_error(51,(100),((1|64)),__FILE__,42); | - | ||||||||||||||||||||||||
| 26 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 27 | } | - | ||||||||||||||||||||||||
| 28 | - | |||||||||||||||||||||||||
| 29 | ; | - | ||||||||||||||||||||||||
| 30 | nctx->currjob = | - | ||||||||||||||||||||||||
| 31 | ((void *)0) | - | ||||||||||||||||||||||||
| 32 | ; | - | ||||||||||||||||||||||||
| 33 | nctx->blocked = 0; | - | ||||||||||||||||||||||||
| 34 | if (!CRYPTO_THREAD_set_local(&ctxkey, nctx)
| 0-5 | ||||||||||||||||||||||||
| 35 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 36 | - | |||||||||||||||||||||||||
| 37 | return executed 5 times by 1 test: nctx;return nctx;Executed by:
executed 5 times by 1 test: return nctx;Executed by:
| 5 | ||||||||||||||||||||||||
| 38 | err: | - | ||||||||||||||||||||||||
| 39 | CRYPTO_free(nctx, __FILE__, 54); | - | ||||||||||||||||||||||||
| 40 | - | |||||||||||||||||||||||||
| 41 | return never executed: return ((void *)0) ;never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||
| 42 | ((void *)0) never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||
| 43 | ; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||
| 44 | } | - | ||||||||||||||||||||||||
| 45 | - | |||||||||||||||||||||||||
| 46 | async_ctx *async_get_ctx(void) | - | ||||||||||||||||||||||||
| 47 | { | - | ||||||||||||||||||||||||
| 48 | return executed 58 times by 1 test: (async_ctx *)CRYPTO_THREAD_get_local(&ctxkey);return (async_ctx *)CRYPTO_THREAD_get_local(&ctxkey);Executed by:
executed 58 times by 1 test: return (async_ctx *)CRYPTO_THREAD_get_local(&ctxkey);Executed by:
| 58 | ||||||||||||||||||||||||
| 49 | } | - | ||||||||||||||||||||||||
| 50 | - | |||||||||||||||||||||||||
| 51 | static int async_ctx_free(void) | - | ||||||||||||||||||||||||
| 52 | { | - | ||||||||||||||||||||||||
| 53 | async_ctx *ctx; | - | ||||||||||||||||||||||||
| 54 | - | |||||||||||||||||||||||||
| 55 | ctx = async_get_ctx(); | - | ||||||||||||||||||||||||
| 56 | - | |||||||||||||||||||||||||
| 57 | if (!CRYPTO_THREAD_set_local(&ctxkey,
| 0-6 | ||||||||||||||||||||||||
| 58 | ((void *)0)
| 0-6 | ||||||||||||||||||||||||
| 59 | )
| 0-6 | ||||||||||||||||||||||||
| 60 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 61 | - | |||||||||||||||||||||||||
| 62 | CRYPTO_free(ctx, __FILE__, 73); | - | ||||||||||||||||||||||||
| 63 | - | |||||||||||||||||||||||||
| 64 | return executed 6 times by 1 test: 1;return 1;Executed by:
executed 6 times by 1 test: return 1;Executed by:
| 6 | ||||||||||||||||||||||||
| 65 | } | - | ||||||||||||||||||||||||
| 66 | - | |||||||||||||||||||||||||
| 67 | static ASYNC_JOB *async_job_new(void) | - | ||||||||||||||||||||||||
| 68 | { | - | ||||||||||||||||||||||||
| 69 | ASYNC_JOB *job = | - | ||||||||||||||||||||||||
| 70 | ((void *)0) | - | ||||||||||||||||||||||||
| 71 | ; | - | ||||||||||||||||||||||||
| 72 | - | |||||||||||||||||||||||||
| 73 | job = CRYPTO_zalloc(sizeof(*job), __FILE__, 82); | - | ||||||||||||||||||||||||
| 74 | if (job ==
| 0-6 | ||||||||||||||||||||||||
| 75 | ((void *)0)
| 0-6 | ||||||||||||||||||||||||
| 76 | ) { | - | ||||||||||||||||||||||||
| 77 | ERR_put_error(51,(102),((1|64)),__FILE__,84); | - | ||||||||||||||||||||||||
| 78 | return never executed: return ((void *)0) ;never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||
| 79 | ((void *)0) never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||
| 80 | ; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||
| 81 | } | - | ||||||||||||||||||||||||
| 82 | - | |||||||||||||||||||||||||
| 83 | job->status = 0; | - | ||||||||||||||||||||||||
| 84 | - | |||||||||||||||||||||||||
| 85 | return executed 6 times by 1 test: job;return job;Executed by:
executed 6 times by 1 test: return job;Executed by:
| 6 | ||||||||||||||||||||||||
| 86 | } | - | ||||||||||||||||||||||||
| 87 | - | |||||||||||||||||||||||||
| 88 | static void async_job_free(ASYNC_JOB *job) | - | ||||||||||||||||||||||||
| 89 | { | - | ||||||||||||||||||||||||
| 90 | if (job !=
| 5-6 | ||||||||||||||||||||||||
| 91 | ((void *)0)
| 5-6 | ||||||||||||||||||||||||
| 92 | ) { | - | ||||||||||||||||||||||||
| 93 | CRYPTO_free(job->funcargs, __FILE__, 96); | - | ||||||||||||||||||||||||
| 94 | async_fibre_free(&job->fibrectx); | - | ||||||||||||||||||||||||
| 95 | CRYPTO_free(job, __FILE__, 98); | - | ||||||||||||||||||||||||
| 96 | } executed 6 times by 1 test: end of blockExecuted by:
| 6 | ||||||||||||||||||||||||
| 97 | } executed 11 times by 1 test: end of blockExecuted by:
| 11 | ||||||||||||||||||||||||
| 98 | - | |||||||||||||||||||||||||
| 99 | static ASYNC_JOB *async_get_pool_job(void) { | - | ||||||||||||||||||||||||
| 100 | ASYNC_JOB *job; | - | ||||||||||||||||||||||||
| 101 | async_pool *pool; | - | ||||||||||||||||||||||||
| 102 | - | |||||||||||||||||||||||||
| 103 | pool = (async_pool *)CRYPTO_THREAD_get_local(&poolkey); | - | ||||||||||||||||||||||||
| 104 | if (pool ==
| 0-8 | ||||||||||||||||||||||||
| 105 | ((void *)0)
| 0-8 | ||||||||||||||||||||||||
| 106 | ) { | - | ||||||||||||||||||||||||
| 107 | - | |||||||||||||||||||||||||
| 108 | - | |||||||||||||||||||||||||
| 109 | - | |||||||||||||||||||||||||
| 110 | - | |||||||||||||||||||||||||
| 111 | if (ASYNC_init_thread(0, 0) == 0
| 0 | ||||||||||||||||||||||||
| 112 | return never executed: return ((void *)0) ;never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||
| 113 | ((void *)0) never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||
| 114 | ; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||
| 115 | pool = (async_pool *)CRYPTO_THREAD_get_local(&poolkey); | - | ||||||||||||||||||||||||
| 116 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 117 | - | |||||||||||||||||||||||||
| 118 | job = sk_ASYNC_JOB_pop(pool->jobs); | - | ||||||||||||||||||||||||
| 119 | if (job ==
| 1-7 | ||||||||||||||||||||||||
| 120 | ((void *)0)
| 1-7 | ||||||||||||||||||||||||
| 121 | ) { | - | ||||||||||||||||||||||||
| 122 | - | |||||||||||||||||||||||||
| 123 | if ((
| 0-7 | ||||||||||||||||||||||||
| 124 | return executed 1 time by 1 test: return ((void *)0) ;Executed by:
executed 1 time by 1 test: return ((void *)0) ;Executed by:
| 1 | ||||||||||||||||||||||||
| 125 | ((void *)0) executed 1 time by 1 test: return ((void *)0) ;Executed by:
| 1 | ||||||||||||||||||||||||
| 126 | ; executed 1 time by 1 test: return ((void *)0) ;Executed by:
| 1 | ||||||||||||||||||||||||
| 127 | - | |||||||||||||||||||||||||
| 128 | job = async_job_new(); | - | ||||||||||||||||||||||||
| 129 | if (job !=
| 0-6 | ||||||||||||||||||||||||
| 130 | ((void *)0)
| 0-6 | ||||||||||||||||||||||||
| 131 | ) { | - | ||||||||||||||||||||||||
| 132 | if (! async_fibre_makecontext(&job->fibrectx)
| 0-6 | ||||||||||||||||||||||||
| 133 | async_job_free(job); | - | ||||||||||||||||||||||||
| 134 | return never executed: return ((void *)0) ;never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||
| 135 | ((void *)0) never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||
| 136 | ; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||
| 137 | } | - | ||||||||||||||||||||||||
| 138 | pool->curr_size++; | - | ||||||||||||||||||||||||
| 139 | } executed 6 times by 1 test: end of blockExecuted by:
| 6 | ||||||||||||||||||||||||
| 140 | } executed 6 times by 1 test: end of blockExecuted by:
| 6 | ||||||||||||||||||||||||
| 141 | return executed 7 times by 1 test: job;return job;Executed by:
executed 7 times by 1 test: return job;Executed by:
| 7 | ||||||||||||||||||||||||
| 142 | } | - | ||||||||||||||||||||||||
| 143 | - | |||||||||||||||||||||||||
| 144 | static void async_release_job(ASYNC_JOB *job) { | - | ||||||||||||||||||||||||
| 145 | async_pool *pool; | - | ||||||||||||||||||||||||
| 146 | - | |||||||||||||||||||||||||
| 147 | pool = (async_pool *)CRYPTO_THREAD_get_local(&poolkey); | - | ||||||||||||||||||||||||
| 148 | CRYPTO_free(job->funcargs, __FILE__, 139); | - | ||||||||||||||||||||||||
| 149 | job->funcargs = | - | ||||||||||||||||||||||||
| 150 | ((void *)0) | - | ||||||||||||||||||||||||
| 151 | ; | - | ||||||||||||||||||||||||
| 152 | sk_ASYNC_JOB_push(pool->jobs, job); | - | ||||||||||||||||||||||||
| 153 | } executed 7 times by 1 test: end of blockExecuted by:
| 7 | ||||||||||||||||||||||||
| 154 | - | |||||||||||||||||||||||||
| 155 | void async_start_func(void) | - | ||||||||||||||||||||||||
| 156 | { | - | ||||||||||||||||||||||||
| 157 | ASYNC_JOB *job; | - | ||||||||||||||||||||||||
| 158 | async_ctx *ctx = async_get_ctx(); | - | ||||||||||||||||||||||||
| 159 | - | |||||||||||||||||||||||||
| 160 | while (1) { | - | ||||||||||||||||||||||||
| 161 | - | |||||||||||||||||||||||||
| 162 | job = ctx->currjob; | - | ||||||||||||||||||||||||
| 163 | job->ret = job->func(job->funcargs); | - | ||||||||||||||||||||||||
| 164 | - | |||||||||||||||||||||||||
| 165 | - | |||||||||||||||||||||||||
| 166 | job->status = 3; | - | ||||||||||||||||||||||||
| 167 | if (!async_fibre_swapcontext(&job->fibrectx,
| 0-1 | ||||||||||||||||||||||||
| 168 | &ctx->dispatcher, 1)
| 0-1 | ||||||||||||||||||||||||
| 169 | - | |||||||||||||||||||||||||
| 170 | - | |||||||||||||||||||||||||
| 171 | - | |||||||||||||||||||||||||
| 172 | - | |||||||||||||||||||||||||
| 173 | ERR_put_error(51,(104),(102),__FILE__,162); | - | ||||||||||||||||||||||||
| 174 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 175 | } executed 1 time by 1 test: end of blockExecuted by:
| 1 | ||||||||||||||||||||||||
| 176 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 177 | - | |||||||||||||||||||||||||
| 178 | int ASYNC_start_job(ASYNC_JOB **job, ASYNC_WAIT_CTX *wctx, int *ret, | - | ||||||||||||||||||||||||
| 179 | int (*func)(void *), void *args, size_t size) | - | ||||||||||||||||||||||||
| 180 | { | - | ||||||||||||||||||||||||
| 181 | async_ctx *ctx; | - | ||||||||||||||||||||||||
| 182 | - | |||||||||||||||||||||||||
| 183 | if (!OPENSSL_init_crypto(0x00000100L,
| 0-17 | ||||||||||||||||||||||||
| 184 | ((void *)0)
| 0-17 | ||||||||||||||||||||||||
| 185 | )
| 0-17 | ||||||||||||||||||||||||
| 186 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 187 | - | |||||||||||||||||||||||||
| 188 | ctx = async_get_ctx(); | - | ||||||||||||||||||||||||
| 189 | if (ctx ==
| 5-12 | ||||||||||||||||||||||||
| 190 | ((void *)0)
| 5-12 | ||||||||||||||||||||||||
| 191 | ) | - | ||||||||||||||||||||||||
| 192 | ctx = async_ctx_new(); executed 5 times by 1 test: ctx = async_ctx_new();Executed by:
| 5 | ||||||||||||||||||||||||
| 193 | if (ctx ==
| 0-17 | ||||||||||||||||||||||||
| 194 | ((void *)0)
| 0-17 | ||||||||||||||||||||||||
| 195 | ) | - | ||||||||||||||||||||||||
| 196 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 197 | - | |||||||||||||||||||||||||
| 198 | if (*
| 8-9 | ||||||||||||||||||||||||
| 199 | ctx->currjob = *job; executed 9 times by 1 test: ctx->currjob = *job;Executed by:
| 9 | ||||||||||||||||||||||||
| 200 | - | |||||||||||||||||||||||||
| 201 | for (;;) { | - | ||||||||||||||||||||||||
| 202 | if (ctx->currjob !=
| 8-25 | ||||||||||||||||||||||||
| 203 | ((void *)0)
| 8-25 | ||||||||||||||||||||||||
| 204 | ) { | - | ||||||||||||||||||||||||
| 205 | if (ctx->currjob->status == 3
| 7-18 | ||||||||||||||||||||||||
| 206 | *ret = ctx->currjob->ret; | - | ||||||||||||||||||||||||
| 207 | ctx->currjob->waitctx = | - | ||||||||||||||||||||||||
| 208 | ((void *)0) | - | ||||||||||||||||||||||||
| 209 | ; | - | ||||||||||||||||||||||||
| 210 | async_release_job(ctx->currjob); | - | ||||||||||||||||||||||||
| 211 | ctx->currjob = | - | ||||||||||||||||||||||||
| 212 | ((void *)0) | - | ||||||||||||||||||||||||
| 213 | ; | - | ||||||||||||||||||||||||
| 214 | *job = | - | ||||||||||||||||||||||||
| 215 | ((void *)0) | - | ||||||||||||||||||||||||
| 216 | ; | - | ||||||||||||||||||||||||
| 217 | return executed 7 times by 1 test: 3;return 3;Executed by:
executed 7 times by 1 test: return 3;Executed by:
| 7 | ||||||||||||||||||||||||
| 218 | } | - | ||||||||||||||||||||||||
| 219 | - | |||||||||||||||||||||||||
| 220 | if (ctx->currjob->status == 1
| 9 | ||||||||||||||||||||||||
| 221 | *job = ctx->currjob; | - | ||||||||||||||||||||||||
| 222 | ctx->currjob->status = 2; | - | ||||||||||||||||||||||||
| 223 | ctx->currjob = | - | ||||||||||||||||||||||||
| 224 | ((void *)0) | - | ||||||||||||||||||||||||
| 225 | ; | - | ||||||||||||||||||||||||
| 226 | return executed 9 times by 1 test: 2;return 2;Executed by:
executed 9 times by 1 test: return 2;Executed by:
| 9 | ||||||||||||||||||||||||
| 227 | } | - | ||||||||||||||||||||||||
| 228 | - | |||||||||||||||||||||||||
| 229 | if (ctx->currjob->status == 2
| 0-9 | ||||||||||||||||||||||||
| 230 | ctx->currjob = *job; | - | ||||||||||||||||||||||||
| 231 | - | |||||||||||||||||||||||||
| 232 | if (!async_fibre_swapcontext(&ctx->dispatcher,
| 0-9 | ||||||||||||||||||||||||
| 233 | &ctx->currjob->fibrectx, 1)
| 0-9 | ||||||||||||||||||||||||
| 234 | ERR_put_error(51,(105),(102),__FILE__,208) | - | ||||||||||||||||||||||||
| 235 | ; | - | ||||||||||||||||||||||||
| 236 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 237 | } | - | ||||||||||||||||||||||||
| 238 | continue; executed 9 times by 1 test: continue;Executed by:
| 9 | ||||||||||||||||||||||||
| 239 | } | - | ||||||||||||||||||||||||
| 240 | - | |||||||||||||||||||||||||
| 241 | - | |||||||||||||||||||||||||
| 242 | ERR_put_error(51,(105),((4|64)),__FILE__,215); | - | ||||||||||||||||||||||||
| 243 | async_release_job(ctx->currjob); | - | ||||||||||||||||||||||||
| 244 | ctx->currjob = | - | ||||||||||||||||||||||||
| 245 | ((void *)0) | - | ||||||||||||||||||||||||
| 246 | ; | - | ||||||||||||||||||||||||
| 247 | *job = | - | ||||||||||||||||||||||||
| 248 | ((void *)0) | - | ||||||||||||||||||||||||
| 249 | ; | - | ||||||||||||||||||||||||
| 250 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 251 | } | - | ||||||||||||||||||||||||
| 252 | - | |||||||||||||||||||||||||
| 253 | - | |||||||||||||||||||||||||
| 254 | if ((
| 1-7 | ||||||||||||||||||||||||
| 255 | ((void *)0)
| 1-7 | ||||||||||||||||||||||||
| 256 | ) | - | ||||||||||||||||||||||||
| 257 | return executed 1 time by 1 test: 1;return 1;Executed by:
executed 1 time by 1 test: return 1;Executed by:
| 1 | ||||||||||||||||||||||||
| 258 | - | |||||||||||||||||||||||||
| 259 | if (args !=
| 0-7 | ||||||||||||||||||||||||
| 260 | ((void *)0)
| 0-7 | ||||||||||||||||||||||||
| 261 | ) { | - | ||||||||||||||||||||||||
| 262 | ctx->currjob->funcargs = CRYPTO_malloc(size, __FILE__, 227); | - | ||||||||||||||||||||||||
| 263 | if (ctx->currjob->funcargs ==
| 0 | ||||||||||||||||||||||||
| 264 | ((void *)0)
| 0 | ||||||||||||||||||||||||
| 265 | ) { | - | ||||||||||||||||||||||||
| 266 | ERR_put_error(51,(105),((1|64)),__FILE__,229); | - | ||||||||||||||||||||||||
| 267 | async_release_job(ctx->currjob); | - | ||||||||||||||||||||||||
| 268 | ctx->currjob = | - | ||||||||||||||||||||||||
| 269 | ((void *)0) | - | ||||||||||||||||||||||||
| 270 | ; | - | ||||||||||||||||||||||||
| 271 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 272 | } | - | ||||||||||||||||||||||||
| 273 | memcpy(ctx->currjob->funcargs, args, size); | - | ||||||||||||||||||||||||
| 274 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 275 | ctx->currjob->funcargs = | - | ||||||||||||||||||||||||
| 276 | ((void *)0) | - | ||||||||||||||||||||||||
| 277 | ; | - | ||||||||||||||||||||||||
| 278 | } executed 7 times by 1 test: end of blockExecuted by:
| 7 | ||||||||||||||||||||||||
| 279 | - | |||||||||||||||||||||||||
| 280 | ctx->currjob->func = func; | - | ||||||||||||||||||||||||
| 281 | ctx->currjob->waitctx = wctx; | - | ||||||||||||||||||||||||
| 282 | if (!async_fibre_swapcontext(&ctx->dispatcher,
| 0-7 | ||||||||||||||||||||||||
| 283 | &ctx->currjob->fibrectx, 1)
| 0-7 | ||||||||||||||||||||||||
| 284 | ERR_put_error(51,(105),(102),__FILE__,243); | - | ||||||||||||||||||||||||
| 285 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 286 | } | - | ||||||||||||||||||||||||
| 287 | } executed 7 times by 1 test: end of blockExecuted by:
| 7 | ||||||||||||||||||||||||
| 288 | - | |||||||||||||||||||||||||
| 289 | err: code before this statement never executed: err: | 0 | ||||||||||||||||||||||||
| 290 | async_release_job(ctx->currjob); | - | ||||||||||||||||||||||||
| 291 | ctx->currjob = | - | ||||||||||||||||||||||||
| 292 | ((void *)0) | - | ||||||||||||||||||||||||
| 293 | ; | - | ||||||||||||||||||||||||
| 294 | *job = | - | ||||||||||||||||||||||||
| 295 | ((void *)0) | - | ||||||||||||||||||||||||
| 296 | ; | - | ||||||||||||||||||||||||
| 297 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 298 | } | - | ||||||||||||||||||||||||
| 299 | - | |||||||||||||||||||||||||
| 300 | int ASYNC_pause_job(void) | - | ||||||||||||||||||||||||
| 301 | { | - | ||||||||||||||||||||||||
| 302 | ASYNC_JOB *job; | - | ||||||||||||||||||||||||
| 303 | async_ctx *ctx = async_get_ctx(); | - | ||||||||||||||||||||||||
| 304 | - | |||||||||||||||||||||||||
| 305 | if (ctx ==
| 9-10 | ||||||||||||||||||||||||
| 306 | ((void *)0)
| 9-10 | ||||||||||||||||||||||||
| 307 | - | |||||||||||||||||||||||||
| 308 | || ctx->currjob ==
| 0-10 | ||||||||||||||||||||||||
| 309 | ((void *)0)
| 0-10 | ||||||||||||||||||||||||
| 310 | - | |||||||||||||||||||||||||
| 311 | || ctx->blocked
| 1-9 | ||||||||||||||||||||||||
| 312 | - | |||||||||||||||||||||||||
| 313 | - | |||||||||||||||||||||||||
| 314 | - | |||||||||||||||||||||||||
| 315 | - | |||||||||||||||||||||||||
| 316 | return executed 10 times by 1 test: 1;return 1;Executed by:
executed 10 times by 1 test: return 1;Executed by:
| 10 | ||||||||||||||||||||||||
| 317 | } | - | ||||||||||||||||||||||||
| 318 | - | |||||||||||||||||||||||||
| 319 | job = ctx->currjob; | - | ||||||||||||||||||||||||
| 320 | job->status = 1; | - | ||||||||||||||||||||||||
| 321 | - | |||||||||||||||||||||||||
| 322 | if (!async_fibre_swapcontext(&job->fibrectx,
| 0-9 | ||||||||||||||||||||||||
| 323 | &ctx->dispatcher, 1)
| 0-9 | ||||||||||||||||||||||||
| 324 | ERR_put_error(51,(103),(102),__FILE__,275); | - | ||||||||||||||||||||||||
| 325 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 326 | } | - | ||||||||||||||||||||||||
| 327 | - | |||||||||||||||||||||||||
| 328 | async_wait_ctx_reset_counts(job->waitctx); | - | ||||||||||||||||||||||||
| 329 | - | |||||||||||||||||||||||||
| 330 | return executed 9 times by 1 test: 1;return 1;Executed by:
executed 9 times by 1 test: return 1;Executed by:
| 9 | ||||||||||||||||||||||||
| 331 | } | - | ||||||||||||||||||||||||
| 332 | - | |||||||||||||||||||||||||
| 333 | static void async_empty_pool(async_pool *pool) | - | ||||||||||||||||||||||||
| 334 | { | - | ||||||||||||||||||||||||
| 335 | ASYNC_JOB *job; | - | ||||||||||||||||||||||||
| 336 | - | |||||||||||||||||||||||||
| 337 | if (!pool
| 0-5 | ||||||||||||||||||||||||
| 338 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 339 | - | |||||||||||||||||||||||||
| 340 | do { | - | ||||||||||||||||||||||||
| 341 | job = sk_ASYNC_JOB_pop(pool->jobs); | - | ||||||||||||||||||||||||
| 342 | async_job_free(job); | - | ||||||||||||||||||||||||
| 343 | } executed 11 times by 1 test: while (jobend of blockExecuted by:
| 5-11 | ||||||||||||||||||||||||
| 344 | } executed 5 times by 1 test: end of blockExecuted by:
| 5 | ||||||||||||||||||||||||
| 345 | - | |||||||||||||||||||||||||
| 346 | int async_init(void) | - | ||||||||||||||||||||||||
| 347 | { | - | ||||||||||||||||||||||||
| 348 | if (!CRYPTO_THREAD_init_local(&ctxkey,
| 0-4 | ||||||||||||||||||||||||
| 349 | ((void *)0)
| 0-4 | ||||||||||||||||||||||||
| 350 | )
| 0-4 | ||||||||||||||||||||||||
| 351 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 352 | - | |||||||||||||||||||||||||
| 353 | if (!CRYPTO_THREAD_init_local(&poolkey,
| 0-4 | ||||||||||||||||||||||||
| 354 | ((void *)0)
| 0-4 | ||||||||||||||||||||||||
| 355 | )
| 0-4 | ||||||||||||||||||||||||
| 356 | CRYPTO_THREAD_cleanup_local(&ctxkey); | - | ||||||||||||||||||||||||
| 357 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 358 | } | - | ||||||||||||||||||||||||
| 359 | - | |||||||||||||||||||||||||
| 360 | return executed 4 times by 1 test: 1;return 1;Executed by:
executed 4 times by 1 test: return 1;Executed by:
| 4 | ||||||||||||||||||||||||
| 361 | } | - | ||||||||||||||||||||||||
| 362 | - | |||||||||||||||||||||||||
| 363 | void async_deinit(void) | - | ||||||||||||||||||||||||
| 364 | { | - | ||||||||||||||||||||||||
| 365 | CRYPTO_THREAD_cleanup_local(&ctxkey); | - | ||||||||||||||||||||||||
| 366 | CRYPTO_THREAD_cleanup_local(&poolkey); | - | ||||||||||||||||||||||||
| 367 | } executed 4 times by 1 test: end of blockExecuted by:
| 4 | ||||||||||||||||||||||||
| 368 | - | |||||||||||||||||||||||||
| 369 | int ASYNC_init_thread(size_t max_size, size_t init_size) | - | ||||||||||||||||||||||||
| 370 | { | - | ||||||||||||||||||||||||
| 371 | async_pool *pool; | - | ||||||||||||||||||||||||
| 372 | size_t curr_size = 0; | - | ||||||||||||||||||||||||
| 373 | - | |||||||||||||||||||||||||
| 374 | if (init_size > max_size
| 0-5 | ||||||||||||||||||||||||
| 375 | ERR_put_error(51,(101),(103),__FILE__,322); | - | ||||||||||||||||||||||||
| 376 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 377 | } | - | ||||||||||||||||||||||||
| 378 | - | |||||||||||||||||||||||||
| 379 | if (!OPENSSL_init_crypto(0x00000100L,
| 0-5 | ||||||||||||||||||||||||
| 380 | ((void *)0)
| 0-5 | ||||||||||||||||||||||||
| 381 | )
| 0-5 | ||||||||||||||||||||||||
| 382 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 383 | - | |||||||||||||||||||||||||
| 384 | if (!ossl_init_thread_start(0x01)
| 0-5 | ||||||||||||||||||||||||
| 385 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 386 | - | |||||||||||||||||||||||||
| 387 | pool = CRYPTO_zalloc(sizeof(*pool), __FILE__, 332); | - | ||||||||||||||||||||||||
| 388 | if (pool ==
| 0-5 | ||||||||||||||||||||||||
| 389 | ((void *)0)
| 0-5 | ||||||||||||||||||||||||
| 390 | ) { | - | ||||||||||||||||||||||||
| 391 | ERR_put_error(51,(101),((1|64)),__FILE__,334); | - | ||||||||||||||||||||||||
| 392 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 393 | } | - | ||||||||||||||||||||||||
| 394 | - | |||||||||||||||||||||||||
| 395 | pool->jobs = sk_ASYNC_JOB_new_reserve( | - | ||||||||||||||||||||||||
| 396 | ((void *)0) | - | ||||||||||||||||||||||||
| 397 | , init_size); | - | ||||||||||||||||||||||||
| 398 | if (pool->jobs ==
| 0-5 | ||||||||||||||||||||||||
| 399 | ((void *)0)
| 0-5 | ||||||||||||||||||||||||
| 400 | ) { | - | ||||||||||||||||||||||||
| 401 | ERR_put_error(51,(101),((1|64)),__FILE__,340); | - | ||||||||||||||||||||||||
| 402 | CRYPTO_free(pool, __FILE__, 341); | - | ||||||||||||||||||||||||
| 403 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 404 | } | - | ||||||||||||||||||||||||
| 405 | - | |||||||||||||||||||||||||
| 406 | pool->max_size = max_size; | - | ||||||||||||||||||||||||
| 407 | - | |||||||||||||||||||||||||
| 408 | - | |||||||||||||||||||||||||
| 409 | while (init_size--
| 0-5 | ||||||||||||||||||||||||
| 410 | ASYNC_JOB *job; | - | ||||||||||||||||||||||||
| 411 | job = async_job_new(); | - | ||||||||||||||||||||||||
| 412 | if (job ==
| 0 | ||||||||||||||||||||||||
| 413 | ((void *)0)
| 0 | ||||||||||||||||||||||||
| 414 | || !async_fibre_makecontext(&job->fibrectx)
| 0 | ||||||||||||||||||||||||
| 415 | - | |||||||||||||||||||||||||
| 416 | - | |||||||||||||||||||||||||
| 417 | - | |||||||||||||||||||||||||
| 418 | - | |||||||||||||||||||||||||
| 419 | async_job_free(job); | - | ||||||||||||||||||||||||
| 420 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 421 | } | - | ||||||||||||||||||||||||
| 422 | job->funcargs = | - | ||||||||||||||||||||||||
| 423 | ((void *)0) | - | ||||||||||||||||||||||||
| 424 | ; | - | ||||||||||||||||||||||||
| 425 | sk_ASYNC_JOB_push(pool->jobs, job); | - | ||||||||||||||||||||||||
| 426 | curr_size++; | - | ||||||||||||||||||||||||
| 427 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 428 | pool->curr_size = curr_size; | - | ||||||||||||||||||||||||
| 429 | if (!CRYPTO_THREAD_set_local(&poolkey, pool)
| 0-5 | ||||||||||||||||||||||||
| 430 | ERR_put_error(51,(101),(101),__FILE__,365); | - | ||||||||||||||||||||||||
| 431 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 432 | } | - | ||||||||||||||||||||||||
| 433 | - | |||||||||||||||||||||||||
| 434 | return executed 5 times by 1 test: 1;return 1;Executed by:
executed 5 times by 1 test: return 1;Executed by:
| 5 | ||||||||||||||||||||||||
| 435 | err: | - | ||||||||||||||||||||||||
| 436 | async_empty_pool(pool); | - | ||||||||||||||||||||||||
| 437 | sk_ASYNC_JOB_free(pool->jobs); | - | ||||||||||||||||||||||||
| 438 | CRYPTO_free(pool, __FILE__, 373); | - | ||||||||||||||||||||||||
| 439 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 440 | } | - | ||||||||||||||||||||||||
| 441 | - | |||||||||||||||||||||||||
| 442 | void async_delete_thread_state(void) | - | ||||||||||||||||||||||||
| 443 | { | - | ||||||||||||||||||||||||
| 444 | async_pool *pool = (async_pool *)CRYPTO_THREAD_get_local(&poolkey); | - | ||||||||||||||||||||||||
| 445 | - | |||||||||||||||||||||||||
| 446 | if (pool !=
| 1-5 | ||||||||||||||||||||||||
| 447 | ((void *)0)
| 1-5 | ||||||||||||||||||||||||
| 448 | ) { | - | ||||||||||||||||||||||||
| 449 | async_empty_pool(pool); | - | ||||||||||||||||||||||||
| 450 | sk_ASYNC_JOB_free(pool->jobs); | - | ||||||||||||||||||||||||
| 451 | CRYPTO_free(pool, __FILE__, 384); | - | ||||||||||||||||||||||||
| 452 | CRYPTO_THREAD_set_local(&poolkey, | - | ||||||||||||||||||||||||
| 453 | ((void *)0) | - | ||||||||||||||||||||||||
| 454 | ); | - | ||||||||||||||||||||||||
| 455 | } executed 5 times by 1 test: end of blockExecuted by:
| 5 | ||||||||||||||||||||||||
| 456 | async_local_cleanup(); | - | ||||||||||||||||||||||||
| 457 | async_ctx_free(); | - | ||||||||||||||||||||||||
| 458 | } executed 6 times by 1 test: end of blockExecuted by:
| 6 | ||||||||||||||||||||||||
| 459 | - | |||||||||||||||||||||||||
| 460 | void ASYNC_cleanup_thread(void) | - | ||||||||||||||||||||||||
| 461 | { | - | ||||||||||||||||||||||||
| 462 | if (!OPENSSL_init_crypto(0x00000100L,
| 0-5 | ||||||||||||||||||||||||
| 463 | ((void *)0)
| 0-5 | ||||||||||||||||||||||||
| 464 | )
| 0-5 | ||||||||||||||||||||||||
| 465 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 466 | - | |||||||||||||||||||||||||
| 467 | async_delete_thread_state(); | - | ||||||||||||||||||||||||
| 468 | } executed 5 times by 1 test: end of blockExecuted by:
| 5 | ||||||||||||||||||||||||
| 469 | - | |||||||||||||||||||||||||
| 470 | ASYNC_JOB *ASYNC_get_current_job(void) | - | ||||||||||||||||||||||||
| 471 | { | - | ||||||||||||||||||||||||
| 472 | async_ctx *ctx; | - | ||||||||||||||||||||||||
| 473 | - | |||||||||||||||||||||||||
| 474 | if (!OPENSSL_init_crypto(0x00000100L,
| 0-8 | ||||||||||||||||||||||||
| 475 | ((void *)0)
| 0-8 | ||||||||||||||||||||||||
| 476 | )
| 0-8 | ||||||||||||||||||||||||
| 477 | return never executed: return ((void *)0) ;never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||
| 478 | ((void *)0) never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||
| 479 | ; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||
| 480 | - | |||||||||||||||||||||||||
| 481 | ctx = async_get_ctx(); | - | ||||||||||||||||||||||||
| 482 | if (ctx ==
| 2-6 | ||||||||||||||||||||||||
| 483 | ((void *)0)
| 2-6 | ||||||||||||||||||||||||
| 484 | ) | - | ||||||||||||||||||||||||
| 485 | return executed 6 times by 1 test: return ((void *)0) ;Executed by:
executed 6 times by 1 test: return ((void *)0) ;Executed by:
| 6 | ||||||||||||||||||||||||
| 486 | ((void *)0) executed 6 times by 1 test: return ((void *)0) ;Executed by:
| 6 | ||||||||||||||||||||||||
| 487 | ; executed 6 times by 1 test: return ((void *)0) ;Executed by:
| 6 | ||||||||||||||||||||||||
| 488 | - | |||||||||||||||||||||||||
| 489 | return executed 2 times by 1 test: ctx->currjob;return ctx->currjob;Executed by:
executed 2 times by 1 test: return ctx->currjob;Executed by:
| 2 | ||||||||||||||||||||||||
| 490 | } | - | ||||||||||||||||||||||||
| 491 | - | |||||||||||||||||||||||||
| 492 | ASYNC_WAIT_CTX *ASYNC_get_wait_ctx(ASYNC_JOB *job) | - | ||||||||||||||||||||||||
| 493 | { | - | ||||||||||||||||||||||||
| 494 | return executed 1 time by 1 test: job->waitctx;return job->waitctx;Executed by:
executed 1 time by 1 test: return job->waitctx;Executed by:
| 1 | ||||||||||||||||||||||||
| 495 | } | - | ||||||||||||||||||||||||
| 496 | - | |||||||||||||||||||||||||
| 497 | void ASYNC_block_pause(void) | - | ||||||||||||||||||||||||
| 498 | { | - | ||||||||||||||||||||||||
| 499 | async_ctx *ctx; | - | ||||||||||||||||||||||||
| 500 | - | |||||||||||||||||||||||||
| 501 | if (!OPENSSL_init_crypto(0x00000100L,
| 0-1 | ||||||||||||||||||||||||
| 502 | ((void *)0)
| 0-1 | ||||||||||||||||||||||||
| 503 | )
| 0-1 | ||||||||||||||||||||||||
| 504 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 505 | - | |||||||||||||||||||||||||
| 506 | ctx = async_get_ctx(); | - | ||||||||||||||||||||||||
| 507 | if (ctx ==
| 0-1 | ||||||||||||||||||||||||
| 508 | ((void *)0)
| 0-1 | ||||||||||||||||||||||||
| 509 | || ctx->currjob ==
| 0-1 | ||||||||||||||||||||||||
| 510 | ((void *)0)
| 0-1 | ||||||||||||||||||||||||
| 511 | ) { | - | ||||||||||||||||||||||||
| 512 | - | |||||||||||||||||||||||||
| 513 | - | |||||||||||||||||||||||||
| 514 | - | |||||||||||||||||||||||||
| 515 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 516 | } | - | ||||||||||||||||||||||||
| 517 | ctx->blocked++; | - | ||||||||||||||||||||||||
| 518 | } executed 1 time by 1 test: end of blockExecuted by:
| 1 | ||||||||||||||||||||||||
| 519 | - | |||||||||||||||||||||||||
| 520 | void ASYNC_unblock_pause(void) | - | ||||||||||||||||||||||||
| 521 | { | - | ||||||||||||||||||||||||
| 522 | async_ctx *ctx; | - | ||||||||||||||||||||||||
| 523 | - | |||||||||||||||||||||||||
| 524 | if (!OPENSSL_init_crypto(0x00000100L,
| 0-1 | ||||||||||||||||||||||||
| 525 | ((void *)0)
| 0-1 | ||||||||||||||||||||||||
| 526 | )
| 0-1 | ||||||||||||||||||||||||
| 527 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 528 | - | |||||||||||||||||||||||||
| 529 | ctx = async_get_ctx(); | - | ||||||||||||||||||||||||
| 530 | if (ctx ==
| 0-1 | ||||||||||||||||||||||||
| 531 | ((void *)0)
| 0-1 | ||||||||||||||||||||||||
| 532 | || ctx->currjob ==
| 0-1 | ||||||||||||||||||||||||
| 533 | ((void *)0)
| 0-1 | ||||||||||||||||||||||||
| 534 | ) { | - | ||||||||||||||||||||||||
| 535 | - | |||||||||||||||||||||||||
| 536 | - | |||||||||||||||||||||||||
| 537 | - | |||||||||||||||||||||||||
| 538 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 539 | } | - | ||||||||||||||||||||||||
| 540 | if (ctx->blocked > 0
| 0-1 | ||||||||||||||||||||||||
| 541 | ctx->blocked--; executed 1 time by 1 test: ctx->blocked--;Executed by:
| 1 | ||||||||||||||||||||||||
| 542 | } executed 1 time by 1 test: end of blockExecuted by:
| 1 | ||||||||||||||||||||||||
| Switch to Source code | Preprocessed file |