Reset outstation event buffer on session teardown (#423)#425
Conversation
The outstation reused the same Session and DatabaseHandle across reconnects without re-arming the event buffer's per-event selection state. An event transmitted but not confirmed before a link drop (or TCP-server session replacement) was stranded in the Written state: never re-selected, never re-reported, and not even advertised in the class IIN. Reset per-connection state (event buffer, transport reader/writer, and session state) from a single RAII guard in OutstationTask::run so it runs on both normal return and future cancellation. This makes session.run() cancel-safe, which the TCP server relies on when it drops the running session future to accept a replacement connection. Add a reconnect-capable, type-state outstation test harness and a regression test that drops the link before CONFIRM and asserts the unconfirmed event is re-armed and re-reported on the next connection. Closes #423.
With the serialization feature, serde_json's `impl PartialEq<serde_json::Value> for u32` makes `expected_handle.into()` ambiguous (E0283). Use the explicit `u32::from(..)` conversion.
Construct AssociationConfig with struct-update syntax instead of mutating fields after Default::default().
Rename the harness submodule file from harness.rs to runner.rs so it no longer shares the name of its containing `harness` module.
There was a problem hiding this comment.
Code Review
This pull request introduces a cancel-safe session teardown mechanism for the outstation task using an RAII guard (SessionTeardown), ensuring that per-connection state is correctly re-armed even if the run future is cancelled. It also refactors the test harness (OutstationHarness) into a type-state pattern with Connected and Disconnected states to enforce connection-state safety at compile time, and adds a regression test for re-arming unconfirmed events after a link drop. Additionally, it cleans up test configurations and file handle conversions. There are no review comments, so I have no feedback to provide.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
Closes #423.