提交 05a6347f 编写于 作者: M Matt Caswell

Tweak async documentation based on feedback

Add some clarifications to the async documentation. Also changed
ASYNC_pause_job() so that it returns success if you are not within the
context of a job. This is so that engines can be used either asynchronously
or synchronously and can treat an error from ASYNC_pause_job() as a real
error.
Reviewed-by: NRich Salz <rsalz@openssl.org>
上级 add2f5ca
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
further details. Libssl has also had this capability integrated with the further details. Libssl has also had this capability integrated with the
introduction of the new mode SSL_MODE_ASYNC and associated error introduction of the new mode SSL_MODE_ASYNC and associated error
SSL_ERROR_WANT_ASYNC. See the SSL_CTX_set_mode() and SSL_get_error() man SSL_ERROR_WANT_ASYNC. See the SSL_CTX_set_mode() and SSL_get_error() man
pages. pages. This work was developed in partnership with Intel Corp.
[Matt Caswell] [Matt Caswell]
*) State machine rewrite. The state machine code has been significantly *) State machine rewrite. The state machine code has been significantly
......
...@@ -280,10 +280,10 @@ int ASYNC_pause_job(void) ...@@ -280,10 +280,10 @@ int ASYNC_pause_job(void)
if(!async_get_ctx() || !async_get_ctx()->currjob) { if(!async_get_ctx() || !async_get_ctx()->currjob) {
/* /*
* Could be we've deliberately not been started within a job so we * Could be we've deliberately not been started within a job so this is
* don't put an error on the error queue here. * counted as success.
*/ */
return 0; return 1;
} }
job = async_get_ctx()->currjob; job = async_get_ctx()->currjob;
......
...@@ -75,6 +75,8 @@ ASYNC_pause_job() below). A handle to the job is placed in B<*job>. Other work ...@@ -75,6 +75,8 @@ ASYNC_pause_job() below). A handle to the job is placed in B<*job>. Other work
can be performed (if desired) and the job restarted at a later time. To restart can be performed (if desired) and the job restarted at a later time. To restart
a job call ASYNC_start_job() again passing the job handle in B<*job>. The a job call ASYNC_start_job() again passing the job handle in B<*job>. The
B<func>, B<args> and B<size> parameters will be ignored when restarting a job. B<func>, B<args> and B<size> parameters will be ignored when restarting a job.
When restarting a job ASYNC_start_job() B<must> be called from the same thread
that the job was originally started from.
=item B<ASYNC_FINISH> =item B<ASYNC_FINISH>
...@@ -83,8 +85,10 @@ be placed in B<*ret>. ...@@ -83,8 +85,10 @@ be placed in B<*ret>.
=back =back
ASYNC_get_current_job() can be used to get a pointer to the currently executing At any one time there can be a maximum of one job actively running per thread
ASYNC_JOB. If no job is currently executing then this will return NULL. (you can have many that are paused). ASYNC_get_current_job() can be used to get
a pointer to the currently executing ASYNC_JOB. If no job is currently executing
then this will return NULL.
If executing within the context of a job (i.e. having been called directly or 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()) indirectly by the function "func" passed as an argument to ASYNC_start_job())
...@@ -99,9 +103,10 @@ Every ASYNC_JOB has a "wait" file descriptor associated with it. Calling ...@@ -99,9 +103,10 @@ Every ASYNC_JOB has a "wait" file descriptor associated with it. Calling
ASYNC_get_wait_fd() and passing in a pointer to an ASYNC_JOB in the B<job> ASYNC_get_wait_fd() and passing in a pointer to an ASYNC_JOB in the B<job>
parameter will return the wait file descriptor associated with that job. This parameter will return the wait file descriptor associated with that job. This
file descriptor can be used to signal that the job should be resumed. file descriptor can be used to signal that the job should be resumed.
Applications can wait on the file descriptor using a system function call Applications can wait for the file descriptor to be ready for "read" using a
such as select or poll. Applications can signal that a job is ready to resume system function call such as select or poll (being ready for "read" indicates
using ASYNC_wake() or clear an existing signal using ASYNC_clear_wake(). that the job should be resumed). Applications can signal that a job is ready to
resume using ASYNC_wake() or clear an existing signal using ASYNC_clear_wake().
An example of typical usage might be an async capable engine. User code would An example of typical usage might be an async capable engine. User code would
initiate cryptographic operations. The engine would initiate those operations initiate cryptographic operations. The engine would initiate those operations
...@@ -109,7 +114,7 @@ asynchronously and then call ASYNC_pause_job() to return control to the user ...@@ -109,7 +114,7 @@ asynchronously and then call ASYNC_pause_job() to return control to the user
code. The user code can then perform other tasks or wait for the job to be ready code. The user code can then perform other tasks or wait for the job to be ready
by calling "select" or other similar function on the wait file descriptor. The by calling "select" or other similar function on the wait file descriptor. The
engine can signal to the user code that the job should be resumed using engine can signal to the user code that the job should be resumed using
ASYNC_wait(). Once resumed the engine would clear the wake signal by calling ASYNC_wake(). Once resumed the engine would clear the wake signal by calling
ASYNC_clear_wake(). ASYNC_clear_wake().
...@@ -120,8 +125,9 @@ ASYNC_init_pool returns 1 on success or 0 otherwise. ...@@ -120,8 +125,9 @@ ASYNC_init_pool returns 1 on success or 0 otherwise.
ASYNC_start_job returns one of ASYNC_ERR, ASYNC_NO_JOBS, ASYNC_PAUSE or ASYNC_start_job returns one of ASYNC_ERR, ASYNC_NO_JOBS, ASYNC_PAUSE or
ASYNC_FINISH as described above. ASYNC_FINISH as described above.
ASYNC_pause_job returns 0 if an error occured (including if called when not ASYNC_pause_job returns 0 if an error occured or 1 on success. If called when
within the context of an ASYNC_JOB), or 1 on success. not within the context of an ASYNC_JOB then this is counted as success so 1 is
returned.
ASYNC_get_wait_fd returns the "wait" file descriptor associated with the ASYNC_get_wait_fd returns the "wait" file descriptor associated with the
ASYNC_JOB provided as an argument. ASYNC_JOB provided as an argument.
......
...@@ -20,10 +20,10 @@ L<SSL_CTX_set_mode(3)>). ...@@ -20,10 +20,10 @@ L<SSL_CTX_set_mode(3)>).
SSL_get_async_wait_fd() returns a file descriptor which can be used in a call to SSL_get_async_wait_fd() returns a file descriptor which can be used in a call to
select() or poll() to determine whether the current asynchronous operation has select() or poll() to determine whether the current asynchronous operation has
completed or not. A completed operation will result in data appearing as completed or not. A completed operation will result in data appearing as
available on the file descriptor (no actual data should be read from the file "read ready" on the file descriptor (no actual data should be read from the
descriptor). This function should only be called if the SSL object is currently file descriptor). This function should only be called if the SSL object is
waiting for asynchronous work to complete (i.e. SSL_ERROR_WANT_ASYNC has been currently waiting for asynchronous work to complete (i.e. SSL_ERROR_WANT_ASYNC
received - see L<SSL_get_error(3)>). has been received - see L<SSL_get_error(3)>).
=head1 RETURN VALUES =head1 RETURN VALUES
......
...@@ -96,7 +96,8 @@ engine is being used. An application can determine whether the engine has ...@@ -96,7 +96,8 @@ engine is being used. An application can determine whether the engine has
completed its processing using select() or poll() on the asynchronous wait file completed its processing using select() or poll() on the asynchronous wait file
descriptor. This file descriptor is available by calling descriptor. This file descriptor is available by calling
L<SSL_get_async_wait_fd(3)>. The TLS/SSL I/O function should be called again L<SSL_get_async_wait_fd(3)>. The TLS/SSL I/O function should be called again
later. later. The function B<must> be called from the same thread that the original
call was made from.
=item SSL_ERROR_SYSCALL =item SSL_ERROR_SYSCALL
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册