fix(abcip): native runtime STRING capacity, mistype churn, malformed-name config error, LWORD type check; non-blocking lease release (#570, #579)

#570
- STRING: the built-in 88-byte Logix STRING holds 82 characters (LEN + DATA[82] + 2 pad), not 84; the
  write still sends the whole 88-byte structure and a read never decodes the pad as characters.
- Mistype churn: a type refusal (CIP 0xFF/0x2107) on the existence read no longer throws from
  InitializeAsync, so the runtime is not disposed/re-created (and re-Forward-Opened) every poll; the driver
  also keeps a runtime that throws TypeMismatch from init and records the device as reachable.
- Malformed tag name: a TagPath that does not parse, or a name the CIP symbolic encoder refuses (now also
  non-ASCII, empty member, >255-char member, unterminated subscript), is AbCipTagConfigurationException ->
  per-tag BadConfigurationError (named const in AbCipStatusMapper), warned once, never feeding the device
  backoff or health; siblings keep reading. A malformed probe tag no longer feeds the backoff either.
- Micro800 BYTE/WORD/LWORD (0xD1/0xD2/0xD4) are type-checked as integers of their width: REAL/LREAL or a
  narrower integer over LWORD is TypeMismatch, not decoded garbage.

#579
- ConnectionLease.ReleaseInBackground: one non-blocking release shape for both native AB runtimes. The
  AbCip runtime's Dispose no longer waits up to 2 s under the per-tag lock; the pool still registers the
  close synchronously so a re-create cannot overlap it. Offline soak tests (25 cycles, AbCip + AbLegacy)
  prove no leaked connection; FakeEipServer gains OpenConnections.

Claude-Session: https://claude.ai/code/session_01Ef2ozxS7QPanGT8uoATbTe
This commit is contained in:
Joseph Doherty
2026-10-07 23:05:49 -04:00
parent 04b6563286
commit 4e6eed7454
17 changed files with 799 additions and 46 deletions
@@ -158,4 +158,29 @@ public sealed class ConnectionLease : IAsyncDisposable
public ValueTask DisposeAsync() =>
Interlocked.Exchange(ref _disposed, 1) == 0 ? _pool.ReleaseAsync(_key, _entry) : ValueTask.CompletedTask;
/// <summary>
/// Releases this lease without waiting for the teardown — the one release shape both native AB tag
/// runtimes use from their synchronous <c>Dispose</c>, which the drivers call under a per-tag lock
/// (Gitea #579). Idempotent, like <see cref="DisposeAsync"/>.
/// </summary>
/// <remarks>
/// <para>Nothing is lost by not waiting. The release's bookkeeping — the ref-count drop and, for the
/// last lease, the entry's removal and the registration of its close in the pool's closing chain — runs
/// synchronously, before this returns. So an acquire made the very next instant builds a connection that
/// does not open until this one's Forward Close + UnRegisterSession have finished (the guarantee the old
/// blocking 2 s wait in the AbCip runtime existed for), and the close itself is bounded by
/// <see cref="CipConnection"/>'s own budgets (the open budget for an in-flight open, 1 s for the Forward
/// Close), so it always completes and the socket is always released.</para>
/// <para>The returned task is the teardown; it never faults (the pool logs its own close failures), so
/// a caller may drop it.</para>
/// </remarks>
/// <returns>The teardown, for tests and callers that want to observe it.</returns>
public Task ReleaseInBackground() => Observe(DisposeAsync());
private static async Task Observe(ValueTask release)
{
try { await release.ConfigureAwait(false); }
catch (Exception) { /* ReleaseAsync logs and swallows its own failures; never fault the observer */ }
}
}