fix(worker): review follow-up — ghost cache entries, ReadBulk dedupe/pumping, fault hygiene
ci / nightly-windev (push) Has been skipped
ci / java (push) Successful in 2m15s
ci / portable (push) Failing after 4m19s
ci / windows-x86 (push) Successful in 6m16s

- AddItem/AddItem2/AddBufferedItem drop stale cache entries for a reused handle id
- ReadBulk: dedupe handles within a batch (advise/teardown once, fan out result);
  pump every 16 items in add/advise and teardown phases
- alarm poll stops without recording a fault once StaRuntime.LoopFault is set
- StaRuntime skips the loop-fault handler during a requested shutdown
- StaHung loop fault diagnostic carries type + HRESULT only
- gateway.md documents ReadBulk's shared deadline
This commit is contained in:
Joseph Doherty
2026-10-22 08:23:05 -04:00
parent 4ea3672b1e
commit 38fbbde191
9 changed files with 375 additions and 21 deletions
@@ -274,6 +274,27 @@ public sealed class StaRuntimeTests
Assert.False(invoked);
}
/// <summary>
/// A loop that throws while a requested shutdown is in progress is
/// being torn down on purpose: the loop-fault handler must not run.
/// </summary>
[Fact]
public void LoopException_DuringRequestedShutdown_DoesNotInvokeHandler()
{
ControllableMessagePump pump = new();
using StaRuntime runtime = new(new RecordingComApartmentInitializer(), pump, TimeSpan.FromSeconds(30));
runtime.Start();
bool invoked = false;
runtime.RegisterLoopFaultHandler(_ => invoked = true);
// The loop is parked in the 30 s idle wait; Shutdown wakes it and the
// very next pump throws with shutdownRequested already set.
pump.ThrowOnNextPump(new InvalidOperationException("pump failed during shutdown"));
Assert.True(runtime.Shutdown(TimeSpan.FromSeconds(5)));
Assert.False(invoked);
}
private static StaRuntime CreateRuntime(RecordingComApartmentInitializer initializer)
{
return new StaRuntime(