Fix deadlock (whoops)

This commit is contained in:
Nadja Reitzenstein 2023-01-18 17:38:32 +01:00
parent 386ac5645d
commit 198845f176
4 changed files with 23 additions and 23 deletions

View File

@ -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);
}
}

View File

@ -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 {

View File

@ -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(())
}
}

View File

@ -179,6 +179,7 @@ impl Resource {
pub fn send_raw(&self, data: Vec<u8>) {
let mut serializer = AllocSerializer::<1024>::default();
let archived = {
let old_state_ref = self.inner.get_state_ref();
let old_state: &ArchivedState = old_state_ref.as_ref();
let m_state: MachineState =
@ -191,7 +192,8 @@ impl Resource {
};
let _ = serializer.serialize_value(&State::with_raw(m_state, data));
let archived = ArchivedValue::new(serializer.into_serializer().into_inner());
ArchivedValue::new(serializer.into_serializer().into_inner())
};
self.inner.set_state(archived);
}