diff options
| author | Steven Fackler <[email protected]> | 2015-12-17 21:26:06 -0800 |
|---|---|---|
| committer | Steven Fackler <[email protected]> | 2015-12-17 21:26:06 -0800 |
| commit | 6195bd4fd8a46ab62cbbc5f654c9743371722dc1 (patch) | |
| tree | 0ccf253c93e6d4923c75ad51744e91dd1839f97f /openssl/src/ssl/bio.rs | |
| parent | Merge branch 'release-v0.7.2' into release (diff) | |
| parent | Release v0.7.3 (diff) | |
| download | rust-openssl-0.7.3.tar.xz rust-openssl-0.7.3.zip | |
Merge branch 'release-v0.7.3' into releasev0.7.3
Diffstat (limited to 'openssl/src/ssl/bio.rs')
| -rw-r--r-- | openssl/src/ssl/bio.rs | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/openssl/src/ssl/bio.rs b/openssl/src/ssl/bio.rs index 1009c0bc..ef63d146 100644 --- a/openssl/src/ssl/bio.rs +++ b/openssl/src/ssl/bio.rs @@ -95,7 +95,7 @@ unsafe extern "C" fn bwrite<S: Write>(bio: *mut BIO, buf: *const c_char, len: c_ match state.stream.write(buf) { Ok(len) => len as c_int, Err(err) => { - if err.kind() == io::ErrorKind::WouldBlock { + if retriable_error(&err) { BIO_set_retry_write(bio); } state.error = Some(err); @@ -112,7 +112,7 @@ unsafe extern "C" fn bread<S: Read>(bio: *mut BIO, buf: *mut c_char, len: c_int) match state.stream.read(buf) { Ok(len) => len as c_int, Err(err) => { - if err.kind() == io::ErrorKind::WouldBlock { + if retriable_error(&err) { BIO_set_retry_read(bio); } state.error = Some(err); @@ -121,6 +121,13 @@ unsafe extern "C" fn bread<S: Read>(bio: *mut BIO, buf: *mut c_char, len: c_int) } } +fn retriable_error(err: &io::Error) -> bool { + match err.kind() { + io::ErrorKind::WouldBlock | io::ErrorKind::NotConnected => true, + _ => false + } +} + unsafe extern "C" fn bputs<S: Write>(bio: *mut BIO, s: *const c_char) -> c_int { bwrite::<S>(bio, s, strlen(s) as c_int) } |