Update for nightly changes

This commit is contained in:
Steven Fackler 2016-04-13 19:30:08 -07:00
parent c48dcde568
commit b94ea8598c
3 changed files with 8 additions and 8 deletions

View File

@ -1,5 +1,5 @@
#![doc(html_root_url="https://sfackler.github.io/rust-openssl/doc/v0.7.9")]
#![cfg_attr(feature = "nightly", feature(const_fn, recover, panic_propagate))]
#![cfg_attr(feature = "nightly", feature(const_fn))]
#[macro_use]
extern crate bitflags;

View File

@ -82,12 +82,12 @@ unsafe fn state<'a, S: 'a>(bio: *mut BIO) -> &'a mut StreamState<S> {
}
#[cfg(feature = "nightly")]
fn recover<F, T>(f: F) -> Result<T, Box<Any + Send>> where F: FnOnce() -> T {
::std::panic::recover(::std::panic::AssertRecoverSafe(f))
fn catch_unwind<F, T>(f: F) -> Result<T, Box<Any + Send>> where F: FnOnce() -> T {
::std::panic::catch_unwind(::std::panic::AssertUnwindSafe(f))
}
#[cfg(not(feature = "nightly"))]
fn recover<F, T>(f: F) -> Result<T, Box<Any + Send>> where F: FnOnce() -> T {
fn catch_unwind<F, T>(f: F) -> Result<T, Box<Any + Send>> where F: FnOnce() -> T {
Ok(f())
}
@ -97,7 +97,7 @@ unsafe extern "C" fn bwrite<S: Write>(bio: *mut BIO, buf: *const c_char, len: c_
let state = state::<S>(bio);
let buf = slice::from_raw_parts(buf as *const _, len as usize);
match recover(|| state.stream.write(buf)) {
match catch_unwind(|| state.stream.write(buf)) {
Ok(Ok(len)) => len as c_int,
Ok(Err(err)) => {
if retriable_error(&err) {
@ -119,7 +119,7 @@ unsafe extern "C" fn bread<S: Read>(bio: *mut BIO, buf: *mut c_char, len: c_int)
let state = state::<S>(bio);
let buf = slice::from_raw_parts_mut(buf as *mut _, len as usize);
match recover(|| state.stream.read(buf)) {
match catch_unwind(|| state.stream.read(buf)) {
Ok(Ok(len)) => len as c_int,
Ok(Err(err)) => {
if retriable_error(&err) {
@ -154,7 +154,7 @@ unsafe extern "C" fn ctrl<S: Write>(bio: *mut BIO,
if cmd == BIO_CTRL_FLUSH {
let state = state::<S>(bio);
match recover(|| state.stream.flush()) {
match catch_unwind(|| state.stream.flush()) {
Ok(Ok(())) => 1,
Ok(Err(err)) => {
state.error = Some(err);

View File

@ -1323,7 +1323,7 @@ impl<S> SslStream<S> {
#[cfg(feature = "nightly")]
fn check_panic(&mut self) {
if let Some(err) = unsafe { bio::take_panic::<S>(self.ssl.get_raw_rbio()) } {
::std::panic::propagate(err)
::std::panic::resume_unwind(err)
}
}