mirror of
https://gitlab.com/fabinfra/fabaccess/bffh.git
synced 2024-11-23 23:27: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> {
|
fn poll(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll<Self::Output> {
|
||||||
// Work until there is no more work to do.
|
// Work until there is no more work to do.
|
||||||
loop {
|
loop {
|
||||||
|
tracing::trace!("polling actor driver");
|
||||||
// Poll the `apply` future. And ensure it's completed before the next one is started
|
// Poll the `apply` future. And ensure it's completed before the next one is started
|
||||||
match self
|
match self
|
||||||
.future
|
.future
|
||||||
@ -89,9 +90,15 @@ where
|
|||||||
Poll::Pending => return Poll::Pending,
|
Poll::Pending => return Poll::Pending,
|
||||||
Poll::Ready(None) => return Poll::Ready(()),
|
Poll::Ready(None) => return Poll::Ready(()),
|
||||||
Poll::Ready(Some(state)) => {
|
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
|
// 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.
|
// 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);
|
self.future.replace(f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,13 +28,6 @@ impl Process {
|
|||||||
pub fn into_boxed_actuator(self) -> Box<dyn Actor + Sync + Send> {
|
pub fn into_boxed_actuator(self) -> Box<dyn Actor + Sync + Send> {
|
||||||
Box::new(self)
|
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 {
|
impl Actor for Process {
|
||||||
|
@ -177,9 +177,7 @@ impl InUseServer for Machine {
|
|||||||
_: inuse::SendRawDataResults,
|
_: inuse::SendRawDataResults,
|
||||||
) -> Promise<(), ::capnp::Error> {
|
) -> Promise<(), ::capnp::Error> {
|
||||||
let data: Vec<u8> = pry!(pry!(params.get()).get_data()).to_vec();
|
let data: Vec<u8> = pry!(pry!(params.get()).get_data()).to_vec();
|
||||||
let resource = self.resource.clone();
|
self.resource.send_raw(data);
|
||||||
let session = self.session.clone();
|
|
||||||
resource.send_raw(data);
|
|
||||||
Promise::ok(())
|
Promise::ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -179,19 +179,21 @@ impl Resource {
|
|||||||
|
|
||||||
pub fn send_raw(&self, data: Vec<u8>) {
|
pub fn send_raw(&self, data: Vec<u8>) {
|
||||||
let mut serializer = AllocSerializer::<1024>::default();
|
let mut serializer = AllocSerializer::<1024>::default();
|
||||||
let old_state_ref = self.inner.get_state_ref();
|
let archived = {
|
||||||
let old_state: &ArchivedState = old_state_ref.as_ref();
|
let old_state_ref = self.inner.get_state_ref();
|
||||||
let m_state: MachineState =
|
let old_state: &ArchivedState = old_state_ref.as_ref();
|
||||||
match Deserialize::<MachineState, _>::deserialize(&old_state.inner, &mut serializer) {
|
let m_state: MachineState =
|
||||||
Ok(s) => s,
|
match Deserialize::<MachineState, _>::deserialize(&old_state.inner, &mut serializer) {
|
||||||
Err(error) => {
|
Ok(s) => s,
|
||||||
tracing::error!(?error, "failed to deserialize stored state!");
|
Err(error) => {
|
||||||
return;
|
tracing::error!(?error, "failed to deserialize stored state!");
|
||||||
}
|
return;
|
||||||
};
|
}
|
||||||
|
};
|
||||||
|
|
||||||
let _ = serializer.serialize_value(&State::with_raw(m_state, data));
|
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);
|
self.inner.set_state(archived);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user