hsclient state: Move error inspection before guard re-lock.

This is still correct from a lock hierarchy pov.  It moves the guard
relock to the end, which is going to be necessary since it is going to
have to move right outside the loop.
This commit is contained in:
Ian Jackson 2023-02-28 14:21:28 +00:00
parent 1e905763e3
commit 4f5f378516
1 changed files with 5 additions and 4 deletions

View File

@ -235,16 +235,17 @@ impl<D: MockableConnectorData> Services<D> {
drop(guard);
// Wait for the task to complete (at which point it drops the barrier)
barrier_recv.recv().await;
guard = connector
.services
.lock()
.map_err(|_| internal!("HS connector poisoned (relock)"))?;
let error = error
.lock()
.map_err(|_| internal!("Working error poisoned"))?;
if let Some(error) = &*error {
return Err(error.clone());
}
drop(error);
guard = connector
.services
.lock()
.map_err(|_| internal!("HS connector poisoned (relock)"))?;
continue;
}
ServiceState::Closed { .. } => {