diff --git a/src/runtime2/component/component_context.rs b/src/runtime2/component/component_context.rs index c0ec092a208d6353fa9f266ed939cc749fb9288a..c02320d58b382798cd59dff48078bd4f00e9b7d6 100644 --- a/src/runtime2/component/component_context.rs +++ b/src/runtime2/component/component_context.rs @@ -14,13 +14,19 @@ pub enum PortInstruction { #[derive(Debug)] pub struct Port { + // Identifiers pub self_id: PortId, pub peer_comp_id: CompId, // eventually consistent pub peer_port_id: PortId, // eventually consistent + // Generic operating state pub kind: PortKind, pub state: PortState, - pub last_instruction: PortInstruction, // used during sync round in case port ends up being closed for error reporting - pub close_at_sync_end: bool, // used during sync round when receiving a `ClosePort(not_in_sync_round)` message + // State tracking for error detection and error handling + pub last_instruction: PortInstruction, // used during sync round to detect port-closed-during-sync errors + pub received_message_for_sync: bool, // used during sync round to detect port-closed-before-sync errors + pub close_at_sync_end: bool, // set during sync round when receiving a port-closed-after-sync message + // Debugging flag to make sure each port is properly associated and + // disassociated with a peer component #[cfg(debug_assertions)] pub(crate) associated_with_peer: bool, } @@ -72,6 +78,7 @@ impl CompCtx { peer_comp_id: self.id, last_instruction: PortInstruction::None, close_at_sync_end: false, + received_message_for_sync: false, #[cfg(debug_assertions)] associated_with_peer: false, }); self.ports.push(Port{ @@ -82,6 +89,7 @@ impl CompCtx { peer_comp_id: self.id, last_instruction: PortInstruction::None, close_at_sync_end: false, + received_message_for_sync: false, #[cfg(debug_assertions)] associated_with_peer: false, }); @@ -95,6 +103,7 @@ impl CompCtx { self_id, peer_comp_id, peer_port_id, kind, state, last_instruction: PortInstruction::None, close_at_sync_end: false, + received_message_for_sync: false, #[cfg(debug_assertions)] associated_with_peer: false, }); return LocalPortHandle(self_id);