Revise the API of "PtMgr::reconfigure"

I prefer that it not take `&mut self`, since PtMgr already has
interior mutability.

I also need it to take `tor_config::Reconfigure` argument, in case
it gains any more smarts about validation in the future.
This commit is contained in:
Nick Mathewson 2022-11-28 14:37:34 -05:00
parent c99017b0d6
commit 3fa86f41a6
1 changed files with 7 additions and 2 deletions

View File

@ -168,12 +168,17 @@ impl<R: Runtime> PtMgr<R> {
/// Reload the configuration /// Reload the configuration
pub fn reconfigure( pub fn reconfigure(
&mut self, &self,
how: tor_config::Reconfigure,
transports: Vec<ManagedTransportConfig>, transports: Vec<ManagedTransportConfig>,
) -> Result<(), tor_config::ReconfigureError> { ) -> Result<(), tor_config::ReconfigureError> {
let configured = Self::transform_config(transports);
if how == tor_config::Reconfigure::CheckAllOrNothing {
return Ok(());
}
{ {
let mut inner = self.state.write().expect("ptmgr poisoned"); let mut inner = self.state.write().expect("ptmgr poisoned");
inner.configured = Self::transform_config(transports); inner.configured = configured;
} }
// We don't have any way of propagating this sanely; the caller will find out the reactor // We don't have any way of propagating this sanely; the caller will find out the reactor
// has died later on anyway. // has died later on anyway.