Skip to content

Reset outstation event buffer on session teardown (#423)#425

Merged
jadamcrain merged 4 commits into
mainfrom
fix/423-event-buffer-reset-on-teardown
Jun 16, 2026
Merged

Reset outstation event buffer on session teardown (#423)#425
jadamcrain merged 4 commits into
mainfrom
fix/423-event-buffer-reset-on-teardown

Conversation

@jadamcrain

Copy link
Copy Markdown
Member

Closes #423.

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.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@jadamcrain jadamcrain merged commit e0135fb into main Jun 16, 2026
31 checks passed
@jadamcrain jadamcrain deleted the fix/423-event-buffer-reset-on-teardown branch June 16, 2026 21:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant