Loading crates/tor-chanmgr/src/err.rs +2 −2 Original line number Diff line number Diff line Loading @@ -74,10 +74,10 @@ impl tor_error::HasKind for Error { use Error as E; use ErrorKind as EK; match self { E::ChanTimeout | E::Io { .. } | E::Proto(ProtoErr::IoErr(_)) => EK::TorConnectionFailed, E::ChanTimeout | E::Io { .. } | E::Proto(ProtoErr::IoErr(_)) => EK::TorAccessFailed, E::Spawn { cause, .. } => cause.kind(), E::Proto(e) => e.kind(), E::PendingFailed => EK::TorConnectionFailed, E::PendingFailed => EK::TorAccessFailed, E::UnusableTarget(_) | E::Internal(_) => EK::Internal, } } Loading crates/tor-circmgr/src/build.rs +8 −3 Original line number Diff line number Diff line Loading @@ -296,13 +296,18 @@ impl<R: Runtime> CircuitBuilder<R> { self.path_config.replace(new_config); } /// Flush state to the state manager. pub(crate) fn save_state(&self) -> Result<()> { /// Flush state to the state manager if we own the lock. /// /// Return `Ok(true)` if we saved, and `Ok(false)` if we didn't hold the lock. pub(crate) fn save_state(&self) -> Result<bool> { if !self.storage.can_store() { return Ok(false); } // TODO: someday we'll want to only do this if there is something // changed. self.builder.timeouts.save_state(&self.storage)?; self.guardmgr.store_persistent_state()?; Ok(()) Ok(true) } /// Replace our state with a new owning state, assuming we have Loading crates/tor-circmgr/src/err.rs +7 −1 Original line number Diff line number Diff line Loading @@ -15,6 +15,9 @@ use tor_linkspec::OwnedChanTarget; pub enum Error { /// We started building a circuit on a guard, but later decided not /// to use that guard. // // TODO: We shouldn't count this as an error for the purposes of the number // of allowable failures of a circuit request. #[error("Discarded circuit because of speculative guard selection")] GuardNotUsable, Loading @@ -27,6 +30,9 @@ pub enum Error { /// Circuits can be cancelled either by a call to /// `retire_all_circuits()`, or by a configuration change that /// makes old paths unusable. // // TODO: We shouldn't count this as an error for the purposes of the number // of allowable failures of a circuit request. #[error("Circuit canceled")] CircCanceled, Loading Loading @@ -136,7 +142,7 @@ impl HasKind for Error { .max_by_key(|e| e.severity()) .map(|e| e.kind()) .unwrap_or(EK::Internal), E::CircCanceled => EK::Canceled, E::CircCanceled => EK::TransientFailure, E::Protocol(e) => e.kind(), E::State(e) => e.kind(), E::GuardMgr(e) => e.kind(), Loading crates/tor-circmgr/src/lib.rs +6 −7 Original line number Diff line number Diff line Loading @@ -258,9 +258,10 @@ impl<R: Runtime> CircMgr<R> { /// Flush state to the state manager, if there is any unsaved state and /// we have the lock. pub fn store_persistent_state(&self) -> Result<()> { self.mgr.peek_builder().save_state()?; Ok(()) /// /// Return true if we saved something; false if we didn't have the lock. pub fn store_persistent_state(&self) -> Result<bool> { self.mgr.peek_builder().save_state() } /// Reconfigure this circuit manager using the latest set of Loading Loading @@ -436,10 +437,8 @@ impl<R: Runtime> CircMgr<R> { impl<R: Runtime> Drop for CircMgr<R> { fn drop(&mut self) { match self.store_persistent_state() { Ok(()) => info!("Flushed persistent state at exit."), Err(Error::State(tor_persist::Error::NoLock)) => { debug!("Lock not held; no state to flush."); } Ok(true) => info!("Flushed persistent state at exit."), Ok(false) => debug!("Lock not held; no state to flush."), Err(e) => error!("Unable to flush state on circuit manager drop: {}", e), } } Loading crates/tor-dirclient/src/err.rs +1 −1 Original line number Diff line number Diff line Loading @@ -95,7 +95,7 @@ impl HasKind for Error { // TODO: it would be good to get more information out of the IoError // in this case, but that would require a bunch of gnarly // downcasting. E::IoError(_) => EK::TorNetworkError, E::IoError(_) => EK::TorDirectoryError, E::Proto(e) => e.kind(), E::CircMgr(e) => e.kind(), E::HttparseError(_) => EK::TorProtocolViolation, Loading Loading
crates/tor-chanmgr/src/err.rs +2 −2 Original line number Diff line number Diff line Loading @@ -74,10 +74,10 @@ impl tor_error::HasKind for Error { use Error as E; use ErrorKind as EK; match self { E::ChanTimeout | E::Io { .. } | E::Proto(ProtoErr::IoErr(_)) => EK::TorConnectionFailed, E::ChanTimeout | E::Io { .. } | E::Proto(ProtoErr::IoErr(_)) => EK::TorAccessFailed, E::Spawn { cause, .. } => cause.kind(), E::Proto(e) => e.kind(), E::PendingFailed => EK::TorConnectionFailed, E::PendingFailed => EK::TorAccessFailed, E::UnusableTarget(_) | E::Internal(_) => EK::Internal, } } Loading
crates/tor-circmgr/src/build.rs +8 −3 Original line number Diff line number Diff line Loading @@ -296,13 +296,18 @@ impl<R: Runtime> CircuitBuilder<R> { self.path_config.replace(new_config); } /// Flush state to the state manager. pub(crate) fn save_state(&self) -> Result<()> { /// Flush state to the state manager if we own the lock. /// /// Return `Ok(true)` if we saved, and `Ok(false)` if we didn't hold the lock. pub(crate) fn save_state(&self) -> Result<bool> { if !self.storage.can_store() { return Ok(false); } // TODO: someday we'll want to only do this if there is something // changed. self.builder.timeouts.save_state(&self.storage)?; self.guardmgr.store_persistent_state()?; Ok(()) Ok(true) } /// Replace our state with a new owning state, assuming we have Loading
crates/tor-circmgr/src/err.rs +7 −1 Original line number Diff line number Diff line Loading @@ -15,6 +15,9 @@ use tor_linkspec::OwnedChanTarget; pub enum Error { /// We started building a circuit on a guard, but later decided not /// to use that guard. // // TODO: We shouldn't count this as an error for the purposes of the number // of allowable failures of a circuit request. #[error("Discarded circuit because of speculative guard selection")] GuardNotUsable, Loading @@ -27,6 +30,9 @@ pub enum Error { /// Circuits can be cancelled either by a call to /// `retire_all_circuits()`, or by a configuration change that /// makes old paths unusable. // // TODO: We shouldn't count this as an error for the purposes of the number // of allowable failures of a circuit request. #[error("Circuit canceled")] CircCanceled, Loading Loading @@ -136,7 +142,7 @@ impl HasKind for Error { .max_by_key(|e| e.severity()) .map(|e| e.kind()) .unwrap_or(EK::Internal), E::CircCanceled => EK::Canceled, E::CircCanceled => EK::TransientFailure, E::Protocol(e) => e.kind(), E::State(e) => e.kind(), E::GuardMgr(e) => e.kind(), Loading
crates/tor-circmgr/src/lib.rs +6 −7 Original line number Diff line number Diff line Loading @@ -258,9 +258,10 @@ impl<R: Runtime> CircMgr<R> { /// Flush state to the state manager, if there is any unsaved state and /// we have the lock. pub fn store_persistent_state(&self) -> Result<()> { self.mgr.peek_builder().save_state()?; Ok(()) /// /// Return true if we saved something; false if we didn't have the lock. pub fn store_persistent_state(&self) -> Result<bool> { self.mgr.peek_builder().save_state() } /// Reconfigure this circuit manager using the latest set of Loading Loading @@ -436,10 +437,8 @@ impl<R: Runtime> CircMgr<R> { impl<R: Runtime> Drop for CircMgr<R> { fn drop(&mut self) { match self.store_persistent_state() { Ok(()) => info!("Flushed persistent state at exit."), Err(Error::State(tor_persist::Error::NoLock)) => { debug!("Lock not held; no state to flush."); } Ok(true) => info!("Flushed persistent state at exit."), Ok(false) => debug!("Lock not held; no state to flush."), Err(e) => error!("Unable to flush state on circuit manager drop: {}", e), } } Loading
crates/tor-dirclient/src/err.rs +1 −1 Original line number Diff line number Diff line Loading @@ -95,7 +95,7 @@ impl HasKind for Error { // TODO: it would be good to get more information out of the IoError // in this case, but that would require a bunch of gnarly // downcasting. E::IoError(_) => EK::TorNetworkError, E::IoError(_) => EK::TorDirectoryError, E::Proto(e) => e.kind(), E::CircMgr(e) => e.kind(), E::HttparseError(_) => EK::TorProtocolViolation, Loading