diff options
| author | Steven Fackler <[email protected]> | 2017-11-04 15:50:35 -0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2017-11-04 15:50:35 -0700 |
| commit | 8e0b69aa7368d5239cb9a43c52d269ad00d25787 (patch) | |
| tree | 9a999676203740b1aecaf5f29c33f27a49ab3094 /openssl/src/ssl/error.rs | |
| parent | Merge pull request #747 from BrianOn99/symm (diff) | |
| parent | Handle local retries (diff) | |
| download | rust-openssl-8e0b69aa7368d5239cb9a43c52d269ad00d25787.tar.xz rust-openssl-8e0b69aa7368d5239cb9a43c52d269ad00d25787.zip | |
Merge pull request #769 from sfackler/want-read
Handle local retries
Diffstat (limited to 'openssl/src/ssl/error.rs')
| -rw-r--r-- | openssl/src/ssl/error.rs | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/openssl/src/ssl/error.rs b/openssl/src/ssl/error.rs index db78e2c8..2244fd7f 100644 --- a/openssl/src/ssl/error.rs +++ b/openssl/src/ssl/error.rs @@ -66,6 +66,33 @@ impl From<ErrorStack> for Error { } } +/// An error indicating that the operation can be immediately retried. +/// +/// OpenSSL's [`SSL_read`] and [`SSL_write`] functions can return `SSL_ERROR_WANT_READ` even when +/// the underlying socket is performing blocking IO in certain cases. When this happens, the +/// the operation can be immediately retried. +/// +/// To signal this event, the `io::Error` inside of [`Error::WantRead`] will be constructed around +/// a `RetryError`. +/// +/// [`SSL_read`]: https://www.openssl.org/docs/manmaster/man3/SSL_read.html +/// [`SSL_write`]: https://www.openssl.org/docs/manmaster/man3/SSL_write.html +/// [`Error::WantRead`]: enum.Error.html#variant.WantRead +#[derive(Debug)] +pub struct RetryError; + +impl fmt::Display for RetryError { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.write_str(error::Error::description(self)) + } +} + +impl error::Error for RetryError { + fn description(&self) -> &str { + "operation must be retried" + } +} + /// An error or intermediate state after a TLS handshake attempt. #[derive(Debug)] pub enum HandshakeError<S> { |