mirror of
https://gitlab.com/fabinfra/fabaccess/bffh.git
synced 2024-11-23 15:17:57 +01:00
Fix deadlock (whoops)
This commit is contained in:
parent
386ac5645d
commit
198845f176
@ -68,6 +68,7 @@ where
|
||||
fn poll(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll<Self::Output> {
|
||||
// Work until there is no more work to do.
|
||||
loop {
|
||||
tracing::trace!("polling actor driver");
|
||||
// Poll the `apply` future. And ensure it's completed before the next one is started
|
||||
match self
|
||||
.future
|
||||
@ -89,9 +90,15 @@ where
|
||||
Poll::Pending => return Poll::Pending,
|
||||
Poll::Ready(None) => return Poll::Ready(()),
|
||||
Poll::Ready(Some(state)) => {
|
||||
tracing::trace!(?state, "actor driver received state update");
|
||||
// This future MUST be polled before we exit from the Actor::poll because if we
|
||||
// do not do that it will not register the dependency and thus NOT BE POLLED.
|
||||
let f = self.actor.apply(state);
|
||||
let f = if self.first {
|
||||
self.first = false;
|
||||
self.actor.restore(state)
|
||||
} else {
|
||||
self.actor.apply(state)
|
||||
};
|
||||
self.future.replace(f);
|
||||
}
|
||||
}
|
||||
|
@ -28,13 +28,6 @@ impl Process {
|
||||
pub fn into_boxed_actuator(self) -> Box<dyn Actor + Sync + Send> {
|
||||
Box::new(self)
|
||||
}
|
||||
|
||||
fn build_command<I, S>(&mut self, state: &ArchivedValue<State>, extra_args: I) -> Command
|
||||
where
|
||||
I: IntoIterator<Item = S>,
|
||||
S: AsRef<std::ffi::OsStr>,
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
impl Actor for Process {
|
||||
|
@ -177,9 +177,7 @@ impl InUseServer for Machine {
|
||||
_: inuse::SendRawDataResults,
|
||||
) -> Promise<(), ::capnp::Error> {
|
||||
let data: Vec<u8> = pry!(pry!(params.get()).get_data()).to_vec();
|
||||
let resource = self.resource.clone();
|
||||
let session = self.session.clone();
|
||||
resource.send_raw(data);
|
||||
self.resource.send_raw(data);
|
||||
Promise::ok(())
|
||||
}
|
||||
}
|
||||
|
@ -179,19 +179,21 @@ impl Resource {
|
||||
|
||||
pub fn send_raw(&self, data: Vec<u8>) {
|
||||
let mut serializer = AllocSerializer::<1024>::default();
|
||||
let old_state_ref = self.inner.get_state_ref();
|
||||
let old_state: &ArchivedState = old_state_ref.as_ref();
|
||||
let m_state: MachineState =
|
||||
match Deserialize::<MachineState, _>::deserialize(&old_state.inner, &mut serializer) {
|
||||
Ok(s) => s,
|
||||
Err(error) => {
|
||||
tracing::error!(?error, "failed to deserialize stored state!");
|
||||
return;
|
||||
}
|
||||
};
|
||||
let archived = {
|
||||
let old_state_ref = self.inner.get_state_ref();
|
||||
let old_state: &ArchivedState = old_state_ref.as_ref();
|
||||
let m_state: MachineState =
|
||||
match Deserialize::<MachineState, _>::deserialize(&old_state.inner, &mut serializer) {
|
||||
Ok(s) => s,
|
||||
Err(error) => {
|
||||
tracing::error!(?error, "failed to deserialize stored state!");
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
let _ = serializer.serialize_value(&State::with_raw(m_state, data));
|
||||
let archived = ArchivedValue::new(serializer.into_serializer().into_inner());
|
||||
let _ = serializer.serialize_value(&State::with_raw(m_state, data));
|
||||
ArchivedValue::new(serializer.into_serializer().into_inner())
|
||||
};
|
||||
self.inner.set_state(archived);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user