diff --git a/src/runtime2/scheduler.rs b/src/runtime2/scheduler.rs index 9ed1ce2cf657e3b23eb5de8932b9253a740d1f03..adf1a5be8bd2bca197139e5483975ede611e42e7 100644 --- a/src/runtime2/scheduler.rs +++ b/src/runtime2/scheduler.rs @@ -130,7 +130,7 @@ impl Scheduler { // Check if the message has to be rerouted because we have moved the // target port to another component. self.debug_conn(connector_id, &format!("Handling message\n --- {:?}", message)); - if let Some(target_port) = Self::get_data_message_target_port(&message) { + if let Some(target_port) = Self::get_message_target_port(&message) { if let Some(other_component_id) = scheduled.router.should_reroute(target_port) { self.debug_conn(connector_id, " ... Rerouting the message"); self.runtime.send_message(other_component_id, message); @@ -221,7 +221,7 @@ impl Scheduler { // the sender must make sure it actually wants to send to // the specified component (and is not using an inconsistent // component ID associated with a port). - content.sync_header.highest_component_id + content.target_component_id }, MessageFancy::Control(_) => { unreachable!("component sending control messages directly"); @@ -246,7 +246,7 @@ impl Scheduler { let mut message_idx = 0; while message_idx < scheduled.ctx_fancy.inbox_messages.len() { let message = &scheduled.ctx_fancy.inbox_messages[message_idx]; - if Self::get_data_message_target_port(message) == Some(port_id) { + if Self::get_message_target_port(message) == Some(port_id) { // Need to transfer this message let message = scheduled.ctx_fancy.inbox_messages.remove(message_idx); new_connector.ctx_fancy.inbox_messages.push(message); @@ -330,9 +330,17 @@ impl Scheduler { } #[inline] - fn get_data_message_target_port(message: &MessageFancy) -> Option { - if let MessageFancy::Data(message) = message { - return Some(message.data_header.target_port) + fn get_message_target_port(message: &MessageFancy) -> Option { + match message { + MessageFancy::Data(data) => return Some(data.data_header.target_port), + MessageFancy::Sync(_) => {}, + MessageFancy::Control(control) => { + match &control.content { + ControlContent::PortPeerChanged(port_id, _) => return Some(*port_id), + ControlContent::CloseChannel(port_id) => return Some(*port_id), + ControlContent::Ping | ControlContent::Ack => {}, + } + }, } return None