From 4de0241463b5a825c59429b4c61a079e763a16fd Mon Sep 17 00:00:00 2001 From: Zhang Jingqiang Date: Wed, 20 Dec 2023 10:51:35 +0800 Subject: [PATCH] add openssl async error code --- openssl-sys/src/ssl.rs | 2 ++ openssl/src/ssl/error.rs | 17 +++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/openssl-sys/src/ssl.rs b/openssl-sys/src/ssl.rs index 52ea5b2135..666a8d58c7 100644 --- a/openssl-sys/src/ssl.rs +++ b/openssl-sys/src/ssl.rs @@ -306,6 +306,8 @@ pub const SSL_ERROR_SSL: c_int = 1; pub const SSL_ERROR_SYSCALL: c_int = 5; pub const SSL_ERROR_WANT_ACCEPT: c_int = 8; pub const SSL_ERROR_WANT_CONNECT: c_int = 7; +pub const SSL_ERROR_WANT_ASYNC: c_int = 9; +pub const SSL_ERROR_WANT_ASYNC_JOB: c_int = 10; pub const SSL_ERROR_WANT_READ: c_int = 2; pub const SSL_ERROR_WANT_WRITE: c_int = 3; pub const SSL_ERROR_WANT_X509_LOOKUP: c_int = 4; diff --git a/openssl/src/ssl/error.rs b/openssl/src/ssl/error.rs index 556583354e..892b72acf9 100644 --- a/openssl/src/ssl/error.rs +++ b/openssl/src/ssl/error.rs @@ -16,6 +16,23 @@ impl ErrorCode { /// The SSL session has been closed. pub const ZERO_RETURN: ErrorCode = ErrorCode(ffi::SSL_ERROR_ZERO_RETURN); + /// The operation did not complete because an asynchronous engine is still + /// processing data. + /// + /// This will only occur if the mode has been set to SSL_MODE_ASYNC. + /// + /// Wait for async engine by using async job APIs and retry the operation. + pub const WANT_ASYNC: ErrorCode = ErrorCode(ffi::SSL_ERROR_WANT_ASYNC); + + /// The asynchronous job could not be started because there were no async jobs + /// available in the pool. + /// + /// This will only occur if the mode has been set to SSL_MODE_ASYNC. + /// + /// Retry the operation after a currently executing asynchronous operation + /// for the current thread has completed + pub const WANT_ASYNC_JOB: ErrorCode = ErrorCode(ffi::SSL_ERROR_WANT_ASYNC_JOB); + /// An attempt to read data from the underlying socket returned `WouldBlock`. /// /// Wait for read readiness and retry the operation.