Software: Apache. PHP/5.6.40 uname -a: Linux cpanel06wh.bkk1.cloud.z.com 2.6.32-954.3.5.lve1.4.80.el6.x86_64 #1 SMP Thu Sep 24 uid=851(cp949260) gid=853(cp949260) groups=853(cp949260) Safe-mode: OFF (not secure) /opt/cpanel/ea-openssl11/share/doc/openssl/html/man3/ drwxr-xr-x |
Viewing file: Select action/file-type:
NAMEASYNC_get_wait_ctx, ASYNC_init_thread, ASYNC_cleanup_thread, ASYNC_start_job, ASYNC_pause_job, ASYNC_get_current_job, ASYNC_block_pause, ASYNC_unblock_pause, ASYNC_is_capable - asynchronous job management functions
SYNOPSIS#include <openssl/async.h> int ASYNC_init_thread(size_t max_size, size_t init_size); void ASYNC_cleanup_thread(void); int ASYNC_start_job(ASYNC_JOB **job, ASYNC_WAIT_CTX *ctx, int *ret, int (*func)(void *), void *args, size_t size); int ASYNC_pause_job(void); ASYNC_JOB *ASYNC_get_current_job(void); ASYNC_WAIT_CTX *ASYNC_get_wait_ctx(ASYNC_JOB *job); void ASYNC_block_pause(void); void ASYNC_unblock_pause(void); int ASYNC_is_capable(void);
DESCRIPTIONOpenSSL implements asynchronous capabilities through an ASYNC_JOB. This represents code that can be started and executes until some event occurs. At that point the code can be paused and control returns to user code until some subsequent event indicates that the job can be resumed. The creation of an ASYNC_JOB is a relatively expensive operation. Therefore, for
efficiency reasons, jobs can be created up front and reused many times. They are
held in a pool until they are needed, at which point they are removed from the
pool, used, and then returned to the pool when the job completes. If the user
application is multi-threaded, then The max_size argument limits the number of ASYNC_JOBs that will be held in
the pool. If max_size is set to 0 then no upper limit is set. When an
ASYNC_JOB is needed but there are none available in the pool already then one
will be automatically created, as long as the total of ASYNC_JOBs managed by the
pool does not exceed max_size. When the pool is first initialised
init_size ASYNC_JOBs will be created immediately. If An asynchronous job is started by calling the
At any one time there can be a maximum of one job actively running per thread
(you can have many that are paused). If executing within the context of a job (i.e. having been called directly or
indirectly by the function "func" passed as an argument to ASYNC_start_job())
then
An example of typical usage might be an async capable engine. User code would
initiate cryptographic operations. The engine would initiate those operations
asynchronously and then call ASYNC_WAIT_CTX_set_wait_fd(3) followed by
The Some platforms cannot support async operations. The
RETURN VALUESASYNC_init_thread returns 1 on success or 0 otherwise. ASYNC_start_job returns one of ASYNC_ERR, ASYNC_NO_JOBS, ASYNC_PAUSE or ASYNC_FINISH as described above. ASYNC_pause_job returns 0 if an error occurred or 1 on success. If called when not within the context of an ASYNC_JOB then this is counted as success so 1 is returned. ASYNC_get_current_job returns a pointer to the currently executing ASYNC_JOB or NULL if not within the context of a job.
NOTESOn Windows platforms the openssl/async.h header is dependent on some of the types customarily made available by including windows.h. The application developer is likely to require control over when the latter is included, commonly as one of the first included headers. Therefore, it is defined as an application developer's responsibility to include windows.h prior to async.h.
EXAMPLESThe following example demonstrates how to use most of the core async APIs: #ifdef _WIN32 # include <windows.h> #endif #include <stdio.h> #include <unistd.h> #include <openssl/async.h> #include <openssl/crypto.h> int unique = 0; void cleanup(ASYNC_WAIT_CTX *ctx, const void *key, OSSL_ASYNC_FD r, void *vw) { OSSL_ASYNC_FD *w = (OSSL_ASYNC_FD *)vw; close(r); close(*w); OPENSSL_free(w); } int jobfunc(void *arg) { ASYNC_JOB *currjob; unsigned char *msg; int pipefds[2] = {0, 0}; OSSL_ASYNC_FD *wptr; char buf = 'X'; currjob = ASYNC_get_current_job(); if (currjob != NULL) { printf("Executing within a job\n"); } else { printf("Not executing within a job - should not happen\n"); return 0; } msg = (unsigned char *)arg; printf("Passed in message is: %s\n", msg); if (pipe(pipefds) != 0) { printf("Failed to create pipe\n"); return 0; } wptr = OPENSSL_malloc(sizeof(OSSL_ASYNC_FD)); if (wptr == NULL) { printf("Failed to malloc\n"); return 0; } *wptr = pipefds[1]; ASYNC_WAIT_CTX_set_wait_fd(ASYNC_get_wait_ctx(currjob), &unique, pipefds[0], wptr, cleanup); /* * Normally some external event would cause this to happen at some * later point - but we do it here for demo purposes, i.e. * immediately signalling that the job is ready to be woken up after * we return to main via ASYNC_pause_job(). */ write(pipefds[1], &buf, 1); /* Return control back to main */ ASYNC_pause_job(); /* Clear the wake signal */ read(pipefds[0], &buf, 1); printf ("Resumed the job after a pause\n"); return 1; } int main(void) { ASYNC_JOB *job = NULL; ASYNC_WAIT_CTX *ctx = NULL; int ret; OSSL_ASYNC_FD waitfd; fd_set waitfdset; size_t numfds; unsigned char msg[13] = "Hello world!"; printf("Starting...\n"); ctx = ASYNC_WAIT_CTX_new(); if (ctx == NULL) { printf("Failed to create ASYNC_WAIT_CTX\n"); abort(); } for (;;) { switch (ASYNC_start_job(&job, ctx, &ret, jobfunc, msg, sizeof(msg))) { case ASYNC_ERR: case ASYNC_NO_JOBS: printf("An error occurred\n"); goto end; case ASYNC_PAUSE: printf("Job was paused\n"); break; case ASYNC_FINISH: printf("Job finished with return value %d\n", ret); goto end; } /* Wait for the job to be woken */ printf("Waiting for the job to be woken up\n"); if (!ASYNC_WAIT_CTX_get_all_fds(ctx, NULL, &numfds) || numfds > 1) { printf("Unexpected number of fds\n"); abort(); } ASYNC_WAIT_CTX_get_all_fds(ctx, &waitfd, &numfds); FD_ZERO(&waitfdset); FD_SET(waitfd, &waitfdset); select(waitfd + 1, &waitfdset, NULL, NULL, NULL); } end: ASYNC_WAIT_CTX_free(ctx); printf("Finishing\n"); return 0; } The expected output from executing the above example program is: Starting... Executing within a job Passed in message is: Hello world! Job was paused Waiting for the job to be woken up Resumed the job after a pause Job finished with return value 1 Finishing
SEE ALSOcrypto(7), ERR_print_errors(3)
HISTORYASYNC_init_thread, ASYNC_cleanup_thread,
ASYNC_start_job, ASYNC_pause_job, ASYNC_get_current_job,
COPYRIGHTCopyright 2015-2020 The OpenSSL Project Authors. All Rights Reserved. Licensed under the OpenSSL license (the "License"). You may not use this file except in compliance with the License. You can obtain a copy in the file LICENSE in the source distribution or at https://www.openssl.org/source/license.html. |
:: Command execute :: | |
--[ c99shell v. 2.0 [PHP 7 Update] [25.02.2019] maintained by KaizenLouie | C99Shell Github | Generation time: 0.0098 ]-- |